Michael,

I took the following lines in
XMLDocumentScannerImpl$ContentDispatcher.resolveExternalSubsetAndRead():

try {
                       
fDTDScanner.setInputSource(src);
                        while
(fDTDScanner.scanDTDExternalSubset(true));
                    }
                    finally {
                       
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
                    } 

And execute them only if the DTD was not found in the
pool:
if(!fValidationManager.isCachedDTD())
                {
                    try {
                       
fDTDScanner.setInputSource(src);
                        while
(fDTDScanner.scanDTDExternalSubset(true));
                    }
                    finally {
                       
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
                    }
                }
                else
                {
                   
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
                }

This seems to take care of the duplicate scanning of
the DTD.

Thanks.
-Raj
--- Michael Glavassevich <[EMAIL PROTECTED]> wrote:

> Hello Raj,
> 
> The grammar pool is only consulted when the document
> has a DTD. Documents 
> without a DOCTYPE don't have one. If you've
> registered an instance of 
> EntityResolver2 with the parser it will call
> getExternalSubset() to give 
> your application an opportunity to provide a DTD,
> effectively inserting a 
> DOCTYPE declaration before the root element with the
> sequence of SAX 
> events your application would receive if there was a
> DOCTYPE present. If 
> you return an InputSource containing external
> identifiers (public id 
> and/or system id) the parser will check if the
> grammar pool already has 
> the DTD, otherwise it will attempt to read from the
> InputStream or Reader. 
> At least this is what the version of Xerces in CVS
> will do. There haven't 
> been any releases which support EntityResolver2 yet
> so you must be using 
> some derivative of the Apache code.
> 
> Ritu Raj Tiwari <[EMAIL PROTECTED]> wrote on
> 02/23/2005 04:37:49 
> PM:
> 
> > >Am I missing something here? If the document has
> no
> > > DOCTYPE declaration there's no DTD to load.
> > 
> > Before using the XMLReader, I set my own
> > EntitResolver2 implementation as the XMLReader's
> > entityResolver. On running in a debugger, For
> > documents that *do* bear a DOCTYPE declaration, I
> see
> > the following method on my entityResolver getting
> > invoked:
> > public InputSource resolveEntity( String name,
> String
> > publicId, String baseURI, String systemId )
> > 
> > This method is getting invoked only *once* when
> the
> > first document is encountered. It is not invoked
> for
> > any future documents, so I can see that the
> caching
> > works. (If I don't configure the parser with a
> grammar
> > pool, this method is called over and over for each
> new
> > XML document).
> > 
> > For documents that don't have a DOCTYPE, the
> following
> > entityResolver method is called: 
> > public InputSource getExternalSubset( String name,
> > String baseURI )
> > 
> > This gets called over and over, despite a matching
> > grammar being found in the pool. I know that
> because I
> > pre-populate the pool with a grammar that has an
> empty
> > XMLGrammarDescription ("::::"). Breakpointing on
> >
> XMLGrammarPoolImpl.getGrammar(XMLGrammarDescription
> > desc) shows this grammar being returned for
> documents
> > without DOCTYPE...and yet, I see the DTD being
> > scanned.
> > 
> > Does this make sense? I'd be happy to provide any
> more
> > information.
> > 
> > Thanks for your responses.
> > -Raj
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > 
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [EMAIL PROTECTED]
> E-mail: [EMAIL PROTECTED]
> 
> 
>
---------------------------------------------------------------------
> 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