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 <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote:
Thanks Alberto

That solved my problem!


On 6/14/06, Alberto Massari <<mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]> 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: <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED] For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]



Reply via email to