Hi Carolina,

At 17.05 15/09/2004 -0400, Carolina Garcia-Paris wrote:
I posted this message yesterday but haven't gotten a response yet.

The bottomline is... has anyone gotten XercesDOMParser::loadGrammar() to
work for loading a DTD grammar in memory and then use it to parse XML files
against it? See my code below. Any hints/recommendations will be greatly
appreciated.

The problem is that DTDs are cached using their system id, but your XML files don't specify one, so they cannot be retrieved back. The only solution is to use a custom XMLValidator.


Try starting with this code

#include <xercesc/validators/common/Grammar.hpp>
#include <xercesc/validators/DTD/DTDValidator.hpp>

...
DOMParser dtdParser;
MemBufInputSource dtdsrc(dtdsource, inputdtd.length(), "VoiceXML");
Grammar* pDTD=dtdParser.loadGrammar(dtdsrc, Grammar::DTDGrammarType, true);
DTDValidator dtdValidator;
dtdValidator.setGrammar(pDTD);

DOMParser VxmlParser(&dtdValidator);
VxmlParser.setValidationScheme(DOMParser::Val_Always);
VxmlParser.parse(...)

Hope this helps,
Alberto



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



Reply via email to