You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Bagepalli, Kiran" <kb...@informatica.com> on 2003/03/21 03:02:28 UTC

How to use cached grammar

I am trying the following piece of code

    XMLPlatformUtils::Initialize();
    SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();

    parser->loadGrammar("d:\\datacenter\\xml\\Storeinfo.dtd",
Grammar::DTDGrammarType, true);
    parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
    parser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);
    parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);

    parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
    parser->setFeature(XMLUni::fgXercesSchema, true);
    parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
    parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, true);
    parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
    parser->setFeature(XMLUni::fgXercesDynamic, true);

    parser->parse("d:\\datacenter\\xml\\Storeinfo.xml");
    XMLPlatformUtils::UnInitialize();

First even though I load the DTD, parse does not seem to find it. In the
code in 
in IGXMLScanner (line 1303)
   Grammar* grammar = fGrammarResolver->getGrammar(sysIdSrc->getSystemId());
always returns NULL.

After that, the parser crashes while doing a scanDocTypeDecl.

Here are the enclosed files. Please copy them to a directory other than the
directory where the exe is present.
Can someone please explain what is wrong.

Thanks
Kiran



 


Re: How to use cached grammar

Posted by Khaled Noaman <kn...@ca.ibm.com>.
The DTD grammar is cached using the system id that you pass when you call load
grammar.
When you parse you xml file, does the system id of the DOCTYPE resolves to the
same id that you passed to load grammar?

"Bagepalli, Kiran" wrote:

> I am trying the following piece of code
>
>     XMLPlatformUtils::Initialize();
>     SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
>
>     parser->loadGrammar("d:\\datacenter\\xml\\Storeinfo.dtd",
> Grammar::DTDGrammarType, true);
>     parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
>     parser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);
>     parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);
>
>     parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
>     parser->setFeature(XMLUni::fgXercesSchema, true);
>     parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
>     parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, true);
>     parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
>     parser->setFeature(XMLUni::fgXercesDynamic, true);
>
>     parser->parse("d:\\datacenter\\xml\\Storeinfo.xml");
>     XMLPlatformUtils::UnInitialize();
>
> First even though I load the DTD, parse does not seem to find it. In the
> code in
> in IGXMLScanner (line 1303)
>    Grammar* grammar = fGrammarResolver->getGrammar(sysIdSrc->getSystemId());
> always returns NULL.
>
> After that, the parser crashes while doing a scanDocTypeDecl.
>
> Here are the enclosed files. Please copy them to a directory other than the
> directory where the exe is present.
> Can someone please explain what is wrong.
>
> Thanks
> Kiran
>
>
>
>   ------------------------------------------------------------------------
>
>    StoreInfo.dtdName: StoreInfo.dtd
>                 Type: unspecified type (application/octet-stream)
>
>    StoreInfo.xmlName: StoreInfo.xml
>                 Type: XML Document (text/xml)
>
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


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