You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Ritu Raj Tiwari <ri...@yahoo.com> on 2005/02/23 03:22:48 UTC

DTD scanned despite being preloaded into grammar pool

My application encounters XML documents that all
conform to the same DTD. I create an XMLReader using
the SAX APIs:
SAXParserFactory factory =
SAXParserFactory.newInstance();
factory.setValidating(bValidating);
SAXParser parser = factory.newSAXParser();
        
XMLReader xmlreader = parser.getXMLReader();
xmlreader.setFeature( XERCES_FEATURE_VALIDATION,
bValidating );

I also set a grammar pool: 
xmlreader.setProperty("http://apache.org/xml/properties/internal/grammar-pool",
grammarPool);

Now, DTD caching seems to work fine for documents that
have a DOCTYPE declaration. But for documents where no
such declaration is present, stepping through the code
shows that xerces loads up the DTD (through entity
resolver) and scans it. It is later able to find the
appropriate DTD in the grammar pool I supplied. 

My questions are:
1. The scanning is wasting CPU cycles that I can't
spare - Is there a way to make xerces back off to a
cached grammar if DOCTYPE declaration is missing?
2. Once it *does* find the cached grammar, I am not
sure if it is using it or parsing the DTD that it
scanned. Does anyone know?

Any help will be greatly appreciated.
Thanks.
Raj

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


Re: DTD scanned despite being preloaded into grammar pool

Posted by Bob Foster <bo...@objfac.com>.
Michael Glavassevich wrote:
> Am I missing something here? If the document has no DOCTYPE declaration 
> there's no DTD to load.

Maybe my assumption was wrong. I assumed he specified it in his code. 
But you're right, it isn't in the code he showed.

Bob


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


Re: DTD scanned despite being preloaded into grammar pool

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Am I missing something here? If the document has no DOCTYPE declaration 
there's no DTD to load.

Bob Foster <bo...@objfac.com> wrote on 02/22/2005 11:00:40 PM:

> Sounds like a bug to me. If the cache is installed, Xerces should use it 

> for every DTD/schema access.
> 
> Bob Foster
> 
> Ritu Raj Tiwari wrote:
> > Now, DTD caching seems to work fine for documents that
> > have a DOCTYPE declaration. But for documents where no
> > such declaration is present, stepping through the code
> > shows that xerces loads up the DTD (through entity
> > resolver) and scans it. It is later able to find the
> > appropriate DTD in the grammar pool I supplied. 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

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


Re: DTD scanned despite being preloaded into grammar pool

Posted by Bob Foster <bo...@objfac.com>.
Sounds like a bug to me. If the cache is installed, Xerces should use it 
for every DTD/schema access.

Bob Foster

Ritu Raj Tiwari wrote:
> Now, DTD caching seems to work fine for documents that
> have a DOCTYPE declaration. But for documents where no
> such declaration is present, stepping through the code
> shows that xerces loads up the DTD (through entity
> resolver) and scans it. It is later able to find the
> appropriate DTD in the grammar pool I supplied. 



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