Hi Udo,

Why are you setting 

   parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false); // (default: 
true)

Namespace processing is rather an integral part of schema assessment. 
Haven't tried in a while, but I'm not sure you can do schema validation 
when this feature is disabled.

Cheers,
Neil
Neil Graham
Manager, XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  [EMAIL PROTECTED]





Udo Schifferdecker <[EMAIL PROTECTED]> 
Sent by: news <[EMAIL PROTECTED]>
05/20/2005 11:28 AM
Please respond to
c-dev


To
[email protected]
cc

Subject
SAX2XMLReader does not honor schema supplied thru loadGrammar()






Hi,

I am trying to validate xml files against a schema using a
SAX2XMLReader. I want to supply the schema thru loadGrammar().
The problem is that loadGrammar seems to work, but the parser
obviously ignores the loaded schema.

Here is my code (I am using xerces 2.4):

<<---snip--->>>
...

   LocalFileInputSource 
mySchemaSource(XMLString::transcode("path_to_schema_file"));

...

   SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();

   // set features
   parser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true); // 
(default: false)
   parser->setFeature(XMLUni::fgSAX2CoreValidation, true); // (default: 
true)
   parser->setFeature(XMLUni::fgXercesDynamic, false); // (default: false)
   parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false); // (default: 
true)
   parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes  , false); // 
(default: false)
   parser->setFeature(XMLUni::fgXercesSchema, true); // (default: true)
   parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true); // 
(default: false)
   parser->setFeature(XMLUni::fgXercesContinueAfterFatalError, false); // 
(default: false)
   parser->setFeature(XMLUni::fgXercesValidationErrorAsFatal, true); // 
(default: false)

   // load the grammar
   if (!parser->loadGrammar(mySchemaSource, (short) 
Grammar::SchemaGrammarType, true /* cache the grammar */))
   {
     // error
     ...
   }

   // set the error handler for validation and debugging
   MyDefaultHandler handler;
   parser->setContentHandler(&handler);
   parser->setErrorHandler(&handler);

   // parse the xml file
   try {
     parser->parse("path_to_xmlFile");
   }

...

<<---snip--->>>


The parsing/validation always fails, because the schema is not found.

Is this a bug or am I doing something wrong?


TIA
Udo







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to