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/grammars/XMLGrammarPool.html#retrieveGrammar(org.apache.xerces.xni.grammars.XMLGrammarDescription) [2] http://xerces.apache.org/xerces2-j/javadocs/xni/org/apache/xerces/xni/grammars/XMLSchemaDescription.html Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED]