On Thu, 2004-09-16 at 08:31, Simon Kitching wrote: > On Thu, 2004-09-16 at 04:02, Fuller, Alex wrote: > > A tangential question: > > Is it necessary to set the externalSchemaLocation property if you > > preload schema Grammars into a GrammarPool? Once the pool is loaded, > > it is given to the parser's configuration. What if the pool is not > > locked? > > > > As I understand it, an XMLGrammarPreparser can figure out the schema's > > namespace as it loads the file. This allows my customers to supply only > > a file location for their schema and not force them to provide the > > namespace, as well. Is this an incorrect approach? > > > > It is necessary to set the property, but the value doesn't matter. > I do something very similar to what you are implementing, and have this > code. Note that in my case rootElementNS is a parameter provided by the > user, and this code runs *before* the parsing starts. > > if (rootElementNS[0] == 0) > { > // The external-noNamespaceSchemaLocation property has to be set > // in order for a root element with no namespace to trigger a > // lookup of targetNamespace "" in the grammar pool. But it > doesn't > // matter what it is set to, because before attempting to load > the > // referenced schema via its location the parser first checks > whether > // there is a preloade grammar with targetNamespace="", and we > have > // just verified above that there is. > XMLCh dummySchemaLocation[] = {chNull}; > parser->setProperty( > XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, > dummySchemaLocation); > } > else > { > // We must disable any previous setting for the property > // externalNoNamespaceSchemaLocation, > parser->setProperty( > XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, > 0); > } > > I hope this helps. >
Umm... as is obvious from the code, this is c++ code using xerces-c. I should watch which list I'm responding to! Sorry.. I would hope that the same principle applies to xerces-j too; I've found the code very similar. Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]