David, Thanks for your reply. I added the two features like this:
pParser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true); pParser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true); And I am seeing the same behavior. Is there any sample code snappet available anywhere? I could'nt find any in the samples provided by Xerces-c package. Thanks again. Frank --- David Bertoni <[EMAIL PROTECTED]> wrote: > Frank Zhou wrote: > > Hi All, > > > > I am using Xerces-c 2.7. I am having a problem > > validating XML against a given DTD (a string). > > > > I am using SAX2XMLReader and using > loadGrammar(...) to > > load the DTD. My code is something like this: > > > > SAX2XMLReader* parser = > > XMLReaderFactory::createXMLReader(); > > > parser->setFeature(XMLUni::fgSAX2CoreValidation, > > m_bValidate); > > parser->setFeature(XMLUni::fgXercesDynamic, > true); > > > > parser->loagGrammar(DTDInputSource, > > Grammar::DTDGrammarType); > > > > parser->setErrorHandler(errorHandler); > > parser->setContentHandler(contentHandler); > > > > parser->parse(XMLinputsource); > > > > I noticed that the validation is not happening, > > invalid xml gets parsed without problem. However, > if I > > don't use loadGrammar(...), instead, I embedded > the > > dtd content into XML input using <!DOCTYPE ... ]>, > > then the validation happens correctly. > > > > Do I need to do some special settings? any problem > > with loadGrammar(...)? > > > > I believe you need to set the feature "use cached > grammar in parse:" > > http://xml.apache.org/xerces-c/program-sax2.html#use-cached > > Not that if you enable the feature to cache the > grammar from the parse, > this feature is automatically enabled: > > http://xml.apache.org/xerces-c/program-sax2.html#cache-grammar > > Dave > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
