You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Alberto Massari <am...@datadirect.com> on 2007/05/22 12:04:31 UTC

Re: Xerces C++ xsd schema validation

Hi Pranav,
if you want to see the errors, you need to register an ErrorHandler.

Alberto

At 15.15 22/05/2007 +0530, Pranav, Savkur wrote:

>Hello Alberto,
>         where can I get code samples that have schema validation of 
> an XML file against an XSD?
>I'm doing these in my code but the validation does not show any errors:
>
>         m_pDOMParser->setExternalNoNamespaceSchemaLocation(strSchemaFile);
>         //Get all errors
>         m_pDOMParser->setExitOnFirstFatalError(true);
>         //All validation errors are fatal.
>         m_pDOMParser->setValidationConstraintFatal(true);
>         //Set the validation scheme
> 
>m_pDOMParser->setValidationScheme(XERCES_CPP_NAMESPACE::XercesDOMParser::Val_Auto 
>);
>         //Set schema validation
>         m_pDOMParser->setValidationSchemaFullChecking(false);
>         //Use namespaces and schema
>         m_pDOMParser->setDoNamespaces(true);
>         m_pDOMParser->setDoSchema(true);
>
>         m_pDOMParser->setIncludeIgnorableWhitespace(false);
>
>Regards,
>Pranav
>
>Disclaimer:
>This e-mail may contain trade secrets or privileged, undisclosed or 
>otherwise confidential information. If you have received this e-mail 
>in error, you are hereby notified that any review, copying or 
>distribution of it is strictly prohibited. Please inform us 
>immediately and destroy the original transmittal. Thank you for your 
>cooperation.


RE: Xerces C++ xsd schema validation

Posted by Alberto Massari <am...@datadirect.com>.
At 18.07 22/05/2007 +0530, Pranav, Savkur wrote:
>Ok but I'm using  XercesDOMParser  with DOMErrorHandler .
>
>Is this still okay?

No, and I don't know how you can fit them; if you are calling 
setErrorHandler((ErrorHandler*)yourDOMErrorHandler) you are just 
shooting in your foot.

Alberto


>-----Original Message-----
>From: ext Alberto Massari [mailto:amassari@datadirect.com]
>Sent: Tuesday, May 22, 2007 5:43 PM
>To: Pranav, Savkur
>Cc: c-users@xerces.apache.org
>Subject: RE: Xerces C++ xsd schema validation
>
>At 17.12 22/05/2007 +0530, Pranav, Savkur wrote:
> >Hello Alberto, thanks for the replies
> >         I have implemented a class that has derived from
> >DOMErrorHandler and implemented the handleError method of that class.
> >Is this fine or the ErrorHandler interface itself must be implemented?
>
>The DOMErrorHandler should be used with the DOMBuilder parser; the
>ErrorHandler should be used with the XercesDOMParser parser.
>They do the same job, but are different interfaces.
>
>Alberto
>
>
> >Regards,
> >Pranav
> >
> >
> >
> >-----Original Message-----
> >From: ext Alberto Massari [mailto:amassari@datadirect.com]
> >Sent: Tuesday, May 22, 2007 4:45 PM
> >To: Pranav, Savkur
> >Cc: c-users@xerces.apache.org
> >Subject: RE: Xerces C++ xsd schema validation
> >
> >Hi Pranav,
> >
> >At 16.31 22/05/2007 +0530, Pranav, Savkur wrote:
> > >Hello Alberto,
> > >
> > >         Is this to be done using the setErrorHandler API of
> > >XercesDOMParser?
> >
> >Yes
> >
> > >         Once the validation fails, must a call be made to one of the
>
> > >errorhandler methods or is the call eventbased?
> >
> >You need to declare a class deriving from the ErrorHandler interface,
> >and implement its virtual methods; the XML engine will call the
> >warning(), error() or fatalError() method of the interface whenever an
> >error occurs. You can then throw a custom exception to abort parsing,
> >or simply store the message in the class and let the XML engine try to
> >continue parsing/validating.
> >
> >Alberto
> >
> >
> > >Regards,
> > >Pranav
> > >
> > >-----Original Message-----
> > >From: ext Alberto Massari [mailto:amassari@datadirect.com]
> > >Sent: Tuesday, May 22, 2007 3:35 PM
> > >To: Pranav, Savkur
> > >Cc: c-users@xerces.apache.org
> > >Subject: Re: Xerces C++ xsd schema validation
> > >
> > >Hi Pranav,
> > >if you want to see the errors, you need to register an ErrorHandler.
> > >
> > >Alberto
> > >
> > >At 15.15 22/05/2007 +0530, Pranav, Savkur wrote:
> > >
> > > >Hello Alberto,
> > > >         where can I get code samples that have schema validation
> > > >of an XML file against an XSD?
> > > >I'm doing these in my code but the validation does not show any
> >errors:
> > > >
> > > >
> > >m_pDOMParser->setExternalNoNamespaceSchemaLocation(strSchemaFile);
> > > >         //Get all errors
> > > >         m_pDOMParser->setExitOnFirstFatalError(true);
> > > >         //All validation errors are fatal.
> > > >         m_pDOMParser->setValidationConstraintFatal(true);
> > > >         //Set the validation scheme
> > > >
> > > >m_pDOMParser->setValidationScheme(XERCES_CPP_NAMESPACE::XercesDOMPa
> > > >rs
> > > >er
> > > >::Val_Auto
> > > >);
> > > >         //Set schema validation
> > > >         m_pDOMParser->setValidationSchemaFullChecking(false);
> > > >         //Use namespaces and schema
> > > >         m_pDOMParser->setDoNamespaces(true);
> > > >         m_pDOMParser->setDoSchema(true);
> > > >
> > > >         m_pDOMParser->setIncludeIgnorableWhitespace(false);
> > > >
> > > >Regards,
> > > >Pranav
> > > >
> > > >Disclaimer:
> > > >This e-mail may contain trade secrets or privileged, undisclosed or
>
> > > >otherwise confidential information. If you have received this
> > > >e-mail in
> > >
> > > >error, you are hereby notified that any review, copying or
> > > >distribution
> > >
> > > >of it is strictly prohibited. Please inform us immediately and
> > > >destroy the original transmittal. Thank you for your cooperation.
> > >
> > >
> > >
> > >
> > >Disclaimer:
> > >This e-mail may contain trade secrets or privileged, undisclosed or
> > >otherwise confidential information. If you have received this e-mail
> > >in
> >
> > >error, you are hereby notified that any review, copying or
> > >distribution
> >
> > >of it is strictly prohibited. Please inform us immediately and
> > >destroy the original transmittal. Thank you for your cooperation.
> >
> >
> >
> >
> >Disclaimer:
> >This e-mail may contain trade secrets or privileged, undisclosed or
> >otherwise confidential information. If you have received this e-mail in
>
> >error, you are hereby notified that any review, copying or distribution
>
> >of it is strictly prohibited. Please inform us immediately and destroy
> >the original transmittal. Thank you for your cooperation.
>
>
>
>
>Disclaimer:
>This e-mail may contain trade secrets or privileged, undisclosed or 
>otherwise confidential information. If you have received this e-mail 
>in error, you are hereby notified that any review, copying or 
>distribution of it is strictly prohibited. Please inform us 
>immediately and destroy the original transmittal. Thank you for your 
>cooperation.


RE: Xerces C++ xsd schema validation

Posted by Alberto Massari <am...@datadirect.com>.
At 17.12 22/05/2007 +0530, Pranav, Savkur wrote:
>Hello Alberto, thanks for the replies
>         I have implemented a class that has derived from DOMErrorHandler
>and implemented the handleError method of that class.
>Is this fine or the ErrorHandler interface itself must be implemented?

The DOMErrorHandler should be used with the DOMBuilder parser; the 
ErrorHandler should be used with the XercesDOMParser parser.
They do the same job, but are different interfaces.

Alberto


>Regards,
>Pranav
>
>
>
>-----Original Message-----
>From: ext Alberto Massari [mailto:amassari@datadirect.com]
>Sent: Tuesday, May 22, 2007 4:45 PM
>To: Pranav, Savkur
>Cc: c-users@xerces.apache.org
>Subject: RE: Xerces C++ xsd schema validation
>
>Hi Pranav,
>
>At 16.31 22/05/2007 +0530, Pranav, Savkur wrote:
> >Hello Alberto,
> >
> >         Is this to be done using the
> >setErrorHandler API of XercesDOMParser?
>
>Yes
>
> >         Once the validation fails, must a call be made to one of the
> >errorhandler methods or is the call eventbased?
>
>You need to declare a class deriving from the ErrorHandler interface,
>and implement its virtual methods; the XML engine will call the
>warning(), error() or fatalError() method of the interface whenever an
>error occurs. You can then throw a custom exception to abort parsing, or
>simply store the message in the class and let the XML engine try to
>continue parsing/validating.
>
>Alberto
>
>
> >Regards,
> >Pranav
> >
> >-----Original Message-----
> >From: ext Alberto Massari [mailto:amassari@datadirect.com]
> >Sent: Tuesday, May 22, 2007 3:35 PM
> >To: Pranav, Savkur
> >Cc: c-users@xerces.apache.org
> >Subject: Re: Xerces C++ xsd schema validation
> >
> >Hi Pranav,
> >if you want to see the errors, you need to register an ErrorHandler.
> >
> >Alberto
> >
> >At 15.15 22/05/2007 +0530, Pranav, Savkur wrote:
> >
> > >Hello Alberto,
> > >         where can I get code samples that have schema validation of
> > >an XML file against an XSD?
> > >I'm doing these in my code but the validation does not show any
>errors:
> > >
> > >
> >m_pDOMParser->setExternalNoNamespaceSchemaLocation(strSchemaFile);
> > >         //Get all errors
> > >         m_pDOMParser->setExitOnFirstFatalError(true);
> > >         //All validation errors are fatal.
> > >         m_pDOMParser->setValidationConstraintFatal(true);
> > >         //Set the validation scheme
> > >
> > >m_pDOMParser->setValidationScheme(XERCES_CPP_NAMESPACE::XercesDOMPars
> > >er
> > >::Val_Auto
> > >);
> > >         //Set schema validation
> > >         m_pDOMParser->setValidationSchemaFullChecking(false);
> > >         //Use namespaces and schema
> > >         m_pDOMParser->setDoNamespaces(true);
> > >         m_pDOMParser->setDoSchema(true);
> > >
> > >         m_pDOMParser->setIncludeIgnorableWhitespace(false);
> > >
> > >Regards,
> > >Pranav
> > >
> > >Disclaimer:
> > >This e-mail may contain trade secrets or privileged, undisclosed or
> > >otherwise confidential information. If you have received this e-mail
> > >in
> >
> > >error, you are hereby notified that any review, copying or
> > >distribution
> >
> > >of it is strictly prohibited. Please inform us immediately and
> > >destroy the original transmittal. Thank you for your cooperation.
> >
> >
> >
> >
> >Disclaimer:
> >This e-mail may contain trade secrets or privileged, undisclosed or
> >otherwise confidential information. If you have received this e-mail in
>
> >error, you are hereby notified that any review, copying or distribution
>
> >of it is strictly prohibited. Please inform us immediately and destroy
> >the original transmittal. Thank you for your cooperation.
>
>
>
>
>Disclaimer:
>This e-mail may contain trade secrets or privileged, undisclosed or 
>otherwise confidential information. If you have received this e-mail 
>in error, you are hereby notified that any review, copying or 
>distribution of it is strictly prohibited. Please inform us 
>immediately and destroy the original transmittal. Thank you for your 
>cooperation.


RE: Xerces C++ xsd schema validation

Posted by Alberto Massari <am...@datadirect.com>.
Hi Pranav,

At 16.31 22/05/2007 +0530, Pranav, Savkur wrote:
>Hello Alberto,
>
>         Is this to be done using the
>setErrorHandler API of XercesDOMParser?

Yes

>         Once the validation fails, must a call be made to one of the
>errorhandler methods or is the call eventbased?

You need to declare a class deriving from the ErrorHandler interface, 
and implement its virtual methods; the XML engine will call the 
warning(), error() or fatalError() method of the interface whenever 
an error occurs. You can then throw a custom exception to abort 
parsing, or simply store the message in the class and let the XML 
engine try to continue parsing/validating.

Alberto


>Regards,
>Pranav
>
>-----Original Message-----
>From: ext Alberto Massari [mailto:amassari@datadirect.com]
>Sent: Tuesday, May 22, 2007 3:35 PM
>To: Pranav, Savkur
>Cc: c-users@xerces.apache.org
>Subject: Re: Xerces C++ xsd schema validation
>
>Hi Pranav,
>if you want to see the errors, you need to register an ErrorHandler.
>
>Alberto
>
>At 15.15 22/05/2007 +0530, Pranav, Savkur wrote:
>
> >Hello Alberto,
> >         where can I get code samples that have schema validation of
> >an XML file against an XSD?
> >I'm doing these in my code but the validation does not show any errors:
> >
> >
>m_pDOMParser->setExternalNoNamespaceSchemaLocation(strSchemaFile);
> >         //Get all errors
> >         m_pDOMParser->setExitOnFirstFatalError(true);
> >         //All validation errors are fatal.
> >         m_pDOMParser->setValidationConstraintFatal(true);
> >         //Set the validation scheme
> >
> >m_pDOMParser->setValidationScheme(XERCES_CPP_NAMESPACE::XercesDOMParser
> >::Val_Auto
> >);
> >         //Set schema validation
> >         m_pDOMParser->setValidationSchemaFullChecking(false);
> >         //Use namespaces and schema
> >         m_pDOMParser->setDoNamespaces(true);
> >         m_pDOMParser->setDoSchema(true);
> >
> >         m_pDOMParser->setIncludeIgnorableWhitespace(false);
> >
> >Regards,
> >Pranav
> >
> >Disclaimer:
> >This e-mail may contain trade secrets or privileged, undisclosed or
> >otherwise confidential information. If you have received this e-mail in
>
> >error, you are hereby notified that any review, copying or distribution
>
> >of it is strictly prohibited. Please inform us immediately and destroy
> >the original transmittal. Thank you for your cooperation.
>
>
>
>
>Disclaimer:
>This e-mail may contain trade secrets or privileged, undisclosed or 
>otherwise confidential information. If you have received this e-mail 
>in error, you are hereby notified that any review, copying or 
>distribution of it is strictly prohibited. Please inform us 
>immediately and destroy the original transmittal. Thank you for your 
>cooperation.