Hi Michael,
 
 
I have changed the code so that retrieveInitialGrammarSet ALWAYS returns
an empty array.
 
I have modified retrieveGrammar to return null if the grammar is a
schema and location hints are null.
 
This does seem to resolve the problem. 
 
Presumably the code should behave in this manner only if dynamic
validation is in force. 
 
Is this what you mean?
 
Cheers
Russell Thamm


________________________________

From: Michael Glavassevich [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 9 September 2008 12:27 PM
To: j-users@xerces.apache.org
Subject: RE: http://apache.org/xml/features/validation/dynamic does not
work as documented



Hi Russell,

"Thamm, Russell" <[EMAIL PROTECTED]> wrote on 09/08/2008
10:23:58 PM:

> Hi Michael,
>  
> I don't understand. The Grammar Pool doesn't seem to have any say in
> the matter.
>  
> I have a schema, say a.xsd and two documents a.xml and b.xml.
>  
> The document a.xml references schema a.xsd and is valid according to
> the schema.
> The document b.xml has the same root element as a.xml but does NOT 
> reference the schema and is not valid according to the schema.
>  
> Assuming a.xsd is in the grammar cache, if I parse b.xml, the only 
> calls to the implementation of GrammarPool are to
retrieveInitialGrammarSet().

Probably because you return all the grammars from the pool from this
method. You don't have to. Your implementation can return a subset or
nothing (i.e. a zero length array) if it chooses.
  
> How does the Grammar Pool know whether or not a schema location hint
> was provided by the instance document?

You get this information when the retrieveGrammar() [1][2] method is
called. It will only be called if your grammar pool hasn't already
returned a grammar for the given target namespace. If your
implementation of retrieveInitialGrammarSet() already returns such a
grammar then retrieveGrammar() will never be called.

> The only info that I get passed is "http://www.w3.org/2001/XMLSchema";
and 
> http://www.w3.org/TR/REC-XML.
>  
> One thing that may be relevant is that my schema don't have a
targetnamespace.
>  
> Cheers
> Russell Thamm

Thanks.

[1]
http://xerces.apache.org/xerces2-j/javadocs/xni/org/apache/xerces/xni/gr
ammars/XMLGrammarPool.html#retrieveGrammar(org.apache.xerces.xni.grammar
s.XMLGrammarDescription)
[2]
http://xerces.apache.org/xerces2-j/javadocs/xni/org/apache/xerces/xni/gr
ammars/XMLSchemaDescription.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED] 


IMPORTANT: This email remains the property of the Australian Defence 
Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 
1914.  If you have received this email in error, you are requested to contact 
the sender and delete the email.


Reply via email to