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 2006/06/14 17:11:30 UTC

Re: [xerces-c] Question on schema validation using DOM

At 11.00 14/06/2006 -0400, Chun Tat David Chu wrote:
>Hi,
>
>I'm currently using Xerces 2.7.0 and I'm having some difficulty to 
>setup my XML parser to validate the schema while parsing a file.
>The current behavior is that even though the XML file contains some 
>invalid schema, but the parser will parse it without flagging it or 
>throwing an exception.
>
>Below is a portion of my code.  Can someone take a look and see if 
>there's anything wrong inside my code that causes the schema validation fail?
>
>XMLPlatformUtils::Initialize();
>
>static const XMLCh gLS[] = {chLatin_L, chLatin_S, chNull };
>
>DOMBuilder::DOMBuilder *domParser_;
>
>DOMImplementation *impl = DOMImplementationRegistry:
>:getDOMImplementation(gLS);
>domParser_ = 
>((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 
>0);
>domParser_->setFeature(XMLUni::fgDOMNamespaces, false);

Namespace processing must be on for schema validation to happen.

Alberto

>domParser_->setFeature(XMLUni::fgXercesSchema, true);
>domParser_->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
>domParser_->setFeature(XMLUni::fgDOMValidateIfSchema, true);
>domParser_->setFeature(XMLUni::fgDOMVlidation, true);
>domParser_->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
>domParser_->setErrorHandler(&myErrorHandler);
>
>Document *doc = 0;
>
>try {
>    domParser_->resetDocumentPool();
>
>    doc = domParser_->parseURI(xmlFileName);
>} catch (...)
>{
>}
>
>Thanks for reading!
>
>- dc


Re: [xerces-c] Question on schema validation using DOM

Posted by Alberto Massari <am...@datadirect.com>.
At 13.42 14/06/2006 -0400, Chun Tat David Chu wrote:
>Sorry, I would like to ask another question.
>
>Why it is necessary to set XMLUni::fgDOMNamespaces to enable schema 
>validation?
>I take it that if your schema definition is not using any namespace, 
>then you can set XMLUni::fgDOMNamespaces to false.

The XMLSchema definition makes use of namespaces (xs:element, 
xs:group, etc...), even if you don't set a target namespace for your elements.

Alberto


>Thanks again,
>
>dc
>
>On 6/14/06, Chun Tat David Chu 
><<m...@gmail.com> wrote:
>Thanks Alberto
>
>That solved my problem!
>
>
>On 6/14/06, Alberto Massari <<m...@datadirect.com> 
>amassari@datadirect.com> wrote:
>At 11.00 14/06/2006 -0400, Chun Tat David Chu wrote:
> >Hi,
> >
> >I'm currently using Xerces 2.7.0 and I'm having some difficulty to
> >setup my XML parser to validate the schema while parsing a file.
> >The current behavior is that even though the XML file contains some
> >invalid schema, but the parser will parse it without flagging it or
> >throwing an exception.
> >
> >Below is a portion of my code.  Can someone take a look and see if
> >there's anything wrong inside my code that causes the schema 
> validation fail?
> >
> >XMLPlatformUtils::Initialize();
> >
> >static const XMLCh gLS[] = {chLatin_L, chLatin_S, chNull };
> >
> >DOMBuilder::DOMBuilder *domParser_;
> >
> >DOMImplementation *impl = DOMImplementationRegistry:
> >:getDOMImplementation(gLS);
> >domParser_ =
> >((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS: 
> :MODE_SYNCHRONOUS,
> >0);
> >domParser_->setFeature(XMLUni::fgDOMNamespaces, false);
>
>Namespace processing must be on for schema validation to happen.
>
>Alberto
>
> >domParser_->setFeature(XMLUni::fgXercesSchema, true);
> >domParser_->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
> >domParser_->setFeature(XMLUni::fgDOMValidateIfSchema, true);
> >domParser_->setFeature(XMLUni::fgDOMVlidation, true);
> >domParser_->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
> >domParser_->setErrorHandler(&myErrorHandler);
> >
> >Document *doc = 0;
> >
> >try {
> >    domParser_->resetDocumentPool();
> >
> >    doc = domParser_->parseURI(xmlFileName);
> >} catch (...)
> >{
> >}
> >
> >Thanks for reading!
> >
> >- dc
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: 
><ma...@xerces.apache.org>c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: 
><ma...@xerces.apache.org>c-dev-help@xerces.apache.org
>
>


Re: [xerces-c] Question on schema validation using DOM

Posted by Alberto Massari <am...@datadirect.com>.
At 13.42 14/06/2006 -0400, Chun Tat David Chu wrote:
>Sorry, I would like to ask another question.
>
>Why it is necessary to set XMLUni::fgDOMNamespaces to enable schema 
>validation?
>I take it that if your schema definition is not using any namespace, 
>then you can set XMLUni::fgDOMNamespaces to false.

The XMLSchema definition makes use of namespaces (xs:element, 
xs:group, etc...), even if you don't set a target namespace for your elements.

Alberto


>Thanks again,
>
>dc
>
>On 6/14/06, Chun Tat David Chu 
><<m...@gmail.com> wrote:
>Thanks Alberto
>
>That solved my problem!
>
>
>On 6/14/06, Alberto Massari <<m...@datadirect.com> 
>amassari@datadirect.com> wrote:
>At 11.00 14/06/2006 -0400, Chun Tat David Chu wrote:
> >Hi,
> >
> >I'm currently using Xerces 2.7.0 and I'm having some difficulty to
> >setup my XML parser to validate the schema while parsing a file.
> >The current behavior is that even though the XML file contains some
> >invalid schema, but the parser will parse it without flagging it or
> >throwing an exception.
> >
> >Below is a portion of my code.  Can someone take a look and see if
> >there's anything wrong inside my code that causes the schema 
> validation fail?
> >
> >XMLPlatformUtils::Initialize();
> >
> >static const XMLCh gLS[] = {chLatin_L, chLatin_S, chNull };
> >
> >DOMBuilder::DOMBuilder *domParser_;
> >
> >DOMImplementation *impl = DOMImplementationRegistry:
> >:getDOMImplementation(gLS);
> >domParser_ =
> >((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS: 
> :MODE_SYNCHRONOUS,
> >0);
> >domParser_->setFeature(XMLUni::fgDOMNamespaces, false);
>
>Namespace processing must be on for schema validation to happen.
>
>Alberto
>
> >domParser_->setFeature(XMLUni::fgXercesSchema, true);
> >domParser_->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
> >domParser_->setFeature(XMLUni::fgDOMValidateIfSchema, true);
> >domParser_->setFeature(XMLUni::fgDOMVlidation, true);
> >domParser_->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
> >domParser_->setErrorHandler(&myErrorHandler);
> >
> >Document *doc = 0;
> >
> >try {
> >    domParser_->resetDocumentPool();
> >
> >    doc = domParser_->parseURI(xmlFileName);
> >} catch (...)
> >{
> >}
> >
> >Thanks for reading!
> >
> >- dc
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: 
><ma...@xerces.apache.org>c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: 
><ma...@xerces.apache.org>c-dev-help@xerces.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: [xerces-c] Question on schema validation using DOM

Posted by Chun Tat David Chu <be...@gmail.com>.
Sorry, I would like to ask another question.

Why it is necessary to set XMLUni::fgDOMNamespaces to enable schema
validation?
I take it that if your schema definition is not using any namespace, then
you can set XMLUni::fgDOMNamespaces to false.

Thanks again,

dc

On 6/14/06, Chun Tat David Chu <be...@gmail.com> wrote:
>
> Thanks Alberto
>
> That solved my problem!
>
>
> On 6/14/06, Alberto Massari <am...@datadirect.com> wrote:
> >
> > At 11.00 14/06/2006 -0400, Chun Tat David Chu wrote:
> > >Hi,
> > >
> > >I'm currently using Xerces 2.7.0 and I'm having some difficulty to
> > >setup my XML parser to validate the schema while parsing a file.
> > >The current behavior is that even though the XML file contains some
> > >invalid schema, but the parser will parse it without flagging it or
> > >throwing an exception.
> > >
> > >Below is a portion of my code.  Can someone take a look and see if
> > >there's anything wrong inside my code that causes the schema validation
> > fail?
> > >
> > >XMLPlatformUtils::Initialize();
> > >
> > >static const XMLCh gLS[] = {chLatin_L, chLatin_S, chNull };
> > >
> > >DOMBuilder::DOMBuilder *domParser_;
> > >
> > >DOMImplementation *impl = DOMImplementationRegistry:
> > >:getDOMImplementation(gLS);
> > >domParser_ =
> >
> > >((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS,
> > >0);
> > >domParser_->setFeature(XMLUni::fgDOMNamespaces, false);
> >
> > Namespace processing must be on for schema validation to happen.
> >
> > Alberto
> >
> > >domParser_->setFeature(XMLUni::fgXercesSchema, true);
> > >domParser_->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
> > >domParser_->setFeature(XMLUni::fgDOMValidateIfSchema, true);
> > >domParser_->setFeature(XMLUni::fgDOMVlidation, true);
> > >domParser_->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
> > >domParser_->setErrorHandler(&myErrorHandler);
> > >
> > >Document *doc = 0;
> > >
> > >try {
> > >    domParser_->resetDocumentPool();
> > >
> > >    doc = domParser_->parseURI(xmlFileName);
> > >} catch (...)
> > >{
> > >}
> > >
> > >Thanks for reading!
> > >
> > >- dc
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: c-dev-help@xerces.apache.org
> >
> >
>

Re: [xerces-c] Question on schema validation using DOM

Posted by Chun Tat David Chu <be...@gmail.com>.
Thanks Alberto

That solved my problem!

On 6/14/06, Alberto Massari <am...@datadirect.com> wrote:
>
> At 11.00 14/06/2006 -0400, Chun Tat David Chu wrote:
> >Hi,
> >
> >I'm currently using Xerces 2.7.0 and I'm having some difficulty to
> >setup my XML parser to validate the schema while parsing a file.
> >The current behavior is that even though the XML file contains some
> >invalid schema, but the parser will parse it without flagging it or
> >throwing an exception.
> >
> >Below is a portion of my code.  Can someone take a look and see if
> >there's anything wrong inside my code that causes the schema validation
> fail?
> >
> >XMLPlatformUtils::Initialize();
> >
> >static const XMLCh gLS[] = {chLatin_L, chLatin_S, chNull };
> >
> >DOMBuilder::DOMBuilder *domParser_;
> >
> >DOMImplementation *impl = DOMImplementationRegistry:
> >:getDOMImplementation(gLS);
> >domParser_ =
>
> >((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS,
> >0);
> >domParser_->setFeature(XMLUni::fgDOMNamespaces, false);
>
> Namespace processing must be on for schema validation to happen.
>
> Alberto
>
> >domParser_->setFeature(XMLUni::fgXercesSchema, true);
> >domParser_->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
> >domParser_->setFeature(XMLUni::fgDOMValidateIfSchema, true);
> >domParser_->setFeature(XMLUni::fgDOMVlidation, true);
> >domParser_->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
> >domParser_->setErrorHandler(&myErrorHandler);
> >
> >Document *doc = 0;
> >
> >try {
> >    domParser_->resetDocumentPool();
> >
> >    doc = domParser_->parseURI(xmlFileName);
> >} catch (...)
> >{
> >}
> >
> >Thanks for reading!
> >
> >- dc
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
>
>