Hi Alberto,
Thanks. I will try and look and see which way is more performant (calling
switchGrammar or calling containsKey). I don't think there are any other
cases where the maps aren't in synch. Of course, orphanGrammar is only
currently called for XMLUni::fgDTDEntityString.
For #2, your fix is a good start. There are a few things I need to modify
(move where Janitor is set for one). The bigger change is that with the
original code the first call to resolveEntity (from getSystemId) only
passes in the systemId. The second call was also passing in the publicId.
So for the other problem I am working on there will still be two calls to
resolveEntity as they aren't resolve using the SystemId so the first one
will fail.
Regards,
David A. Cargill
XML Parser Development
IBM Toronto Lab
(905) 413-2371, tie 969
[EMAIL PROTECTED]
Alberto Massari
<[EMAIL PROTECTED]
s.com> To
[EMAIL PROTECTED]
12/03/2004 12:14 cc
PM
Subject
Re: DTD caching problems
Please respond to
xerces-c-dev
Hi David,
At 12.05 03/12/2004 -0500, David Cargill wrote:
>Hi Alberto,
>Looks like we are both working on the same problem. I have a different
>solution for #1 and that is to call switchGrammar in scanDocType. That is
>what happens in IGXMLScanner but not DGXMLScanner and that is why it works
>for IG and not DG.
I have thought about that, but I think that changing orphanGrammar would be
a safer also for other cases when we forget to keep the two maps in synch.
But feel free to revert my change.
>For #2, still looking at how to avoid the 2nd call. Another customer
>reported a similar problem as this as well...
Have a look at what I committed, and let me know if this solves your
problem too.
Alberto
>Regards,
>David A. Cargill
>XML Parser Development
>IBM Toronto Lab
>(905) 413-2371, tie 969
>[EMAIL PROTECTED]
>
>
>
> Alberto Massari
> <[EMAIL PROTECTED]
> s.com>
To
> [EMAIL PROTECTED]
> 12/03/2004 11:51
cc
> AM
>
Subject
> Re: DTD caching problems
> Please respond to
> xerces-c-dev
>
>
>
>
>
>
>
>
>Hi Daniel,
>I have looked at the testcase you submitted, and I found two things:
>1) the exception you get when using cached grammars and the DGXMLScanner
is
>
>caused by GrammarResolver::orphanGrammar; to fix it, apply this diff
>
>diff -u -r1.29 GrammarResolver.cpp
>--- GrammarResolver.cpp 29 Sep 2004 19:27:07 -0000 1.29
>+++ GrammarResolver.cpp 3 Dec 2004 16:16:23 -0000
>@@ -439,7 +439,8 @@
> Grammar* grammar = fGrammarPool->orphanGrammar(nameSpaceKey);
> if (grammar)
> {
>- fGrammarFromPool->removeKey(nameSpaceKey);
>+ if (fGrammarFromPool->containsKey(nameSpaceKey))
>+ fGrammarFromPool->removeKey(nameSpaceKey);
> return grammar;
> }
> // It failed to remove it from the grammar pool either because
it
>
>2) as for the extra resolveEntity() you see, it's by design;
>GrammarResolver now stores the DTDs using their systemID as key (instead
of
>
>the root element name), so, when caching is on, an extra call to
>resolveEntity is done in order to be able to invoke
>InputSource::getSystemId(). At that point, if the systemId is already in
>the cache, the input source is not parsed; if it is not in the cache, a
new
>
>reader is created (and this triggers a new resolveEntity call)
>I will change this to at least avoid the second call (as we have already
>resolved the DTD).
>
>Thanks for the testcase,
>Alberto
>
>At 16.42 03/12/2004 +1100, Daniel McLean wrote:
> >I've put together a demo based on one of the sample programs shipped
with
> >Xerces. The demo creates a Xerces GrammarPoolImpl then conducts a
number
> >of validating XML parses using that grammar pool when caching is enabled
> >for the parser. The test documents include an XML file referring to a
DTD
> >and an XML file referring to an XML schema. Each type of parse is done
> >twice in succession to observe the caching behaviour of Xerces, with a
new
> >parser instance created for each parse. The parses done include:
> >
> > DGXMLScanner without caching involving DTD validation
> > DGXMLScanner with caching involving DTD validation
> >
> > IGXMLScanner without caching involving DTD validation
> > IGXMLScanner with caching involving DTD validation
> >
> > SGXMLScanner without caching involving XML schema validation
> > SGXMLScanner with caching involving XML schema validation
> >
> >I ran with on an Fedora Core 1 linux x86 platform using Xerces 2.6.0.
> >
> >I see a number of surprising things (refer to output below):
> > - parsing fails when caching is enabled whilst using the DGXMLScanner
> > - when using DGXMLScanner or IGXMLScanner for DTD validation, the DTD
> > appears to be re-resolved for each parse. I haven't checked whether
> > the DTD is actually being re-parsed after being resolved each time,
>but
> > I wonder why it is being resolved each time if it is supposedly
being
> > cached
> > - the DTD is being resolved twice on the first parse when parsing with
a
> > DTD and caching enabled. This seems questionable.
> >
> >I've attached a tarball containing the files for the demo, which should
> >work after being unpacked into the samples directory.
> >
> >Regards,
> >
> >Daniel
> >
> >doParse dtdDGXML
> >parse #1
> >resolveEntity("", "example.dtd")
> >parse #2
> >resolveEntity("", "example.dtd")
> >----------------------------
> >doParse dtdDGXMLCaching
> >parse #1
> >resolveEntity(null, "example.dtd")
> >resolveEntity("", "example.dtd")
> >
> >Fatal Error at (file
>
>/home/daniel/xerces/xerces-c-src_2_6_0/samples/GrammarCache/example-dtd.xml,
>
> >line 2, char 40): An exception occurred! Type:NoSuchElementException,
> >Message:The key '{0}' could not be found in the hash table
> >parse #2
> >resolveEntity(null, "example.dtd")
> >resolveEntity("", "example.dtd")
> >
> >Fatal Error at (file
>
>/home/daniel/xerces/xerces-c-src_2_6_0/samples/GrammarCache/example-dtd.xml,
>
> >line 2, char 40): An exception occurred! Type:NoSuchElementException,
> >Message:The key '{0}' could not be found in the hash table
> >----------------------------
> >doParse dtdIGXML
> >parse #1
> >resolveEntity("", "example.dtd")
> >parse #2
> >resolveEntity("", "example.dtd")
> >----------------------------
> >doParse dtdIGXMLCaching
> >parse #1
> >resolveEntity("", "example.dtd")
> >resolveEntity("", "example.dtd")
> >parse #2
> >resolveEntity("", "example.dtd")
> >----------------------------
> >doParse xsd
> >parse #1
> >resolveEntity("", "example.xsd")
> >parse #2
> >resolveEntity("", "example.xsd")
> >----------------------------
> >doParse xsdCaching
> >parse #1
> >resolveEntity("", "example.xsd")
> >parse #2
> >----------------------------
> >
> >---------------------------------------------------------------------
> >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]
>
>
>
>
>---------------------------------------------------------------------
>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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]