Many thanks Michael for the response. I'll look at your suggestions. I was
guessing that I'd need a custom entity resolver.
Michael Glavassevich wrote:
Hi Rusty,
Have you tried plugging in an XML Catalog [1] or custom entity resolver
[2]? This can be used to redirect from a resource on the net to a local
file (or a zero byte stream if you don't want to load anything).
Also, if this is new code that you're writing I'd suggest using the
standard JAXP Validation API [3][4] for grammar caching rather than the
Xerces specific ones which predated it. In 2010, I'd only recommend
folks use a grammar pool directly if they have some special need that
isn't satisfied by JAXP.
Thanks.
[1] http://xerces.apache.org/xerces2-j/faq-xcatalogs.html
[2]
http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/EntityResolver.html
[3]
http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/validation/SchemaFactory.html
[4]
http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/parsers/SAXParserFactory.html#setSchema(javax.xml.validation.Schema)
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org
Rusty Wright <rwright.li...@gmail.com> wrote on 12/21/2009 08:02:45 PM:
> I'm trying to write a data loader for integration tests for Google's
> Big Table. I've written the schema. I figured it would be a good
> idea to use the grammar pool feature to speed things up. How can I
> stop Xerces from using the network (my guess is it's validating my
> schema)? I'm using most of the code from the sample for the grammar
> builder. I tried changing features from true to false but it's
> still going out to the network; there must be some magic combination
> I've missed.
>
> Here's my code:
>
> public void buildGrammar(final String schemaPath) throws Exception {
> final SymbolTable sym = new
SymbolTable(XmlGrammarBuilder.BIG_PRIME);
> final XMLGrammarPoolImpl grammarPool = new XMLGrammarPoolImpl();
>
> final XMLGrammarPreparser preparser = new
XMLGrammarPreparser(sym);
>
> preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA,
null);
>
> preparser.setProperty(XmlGrammarBuilder.GRAMMAR_POOL,
grammarPool);
>
> preparser.setFeature(XmlFeatures.NAMESPACES.uri(), true);
> preparser.setFeature(XmlFeatures.VALIDATION.uri(), true);
>
> preparser.setFeature(XmlFeatures.VALIDATION_SCHEMA.uri(), true);
> preparser.setFeature(XmlFeatures.SCHEMA_FULL_CHECKING.uri(),
true);
>
preparser.setFeature(XmlFeatures.HONOUR_ALL_SCHEMA_LOCATIONS.uri(),
> true);
>
preparser.setFeature(XmlFeatures.STANDARD_URI_CONFORMANT.uri(), true);
>
> preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,
> new XMLInputSource(null, schemaPath, null));
>
> final XMLParserConfiguration parserConfiguration =
> new XIncludeAwareParserConfiguration(sym, grammarPool);
>
> parserConfiguration.setFeature(XmlFeatures.NAMESPACES.uri(),
true);
> parserConfiguration.setFeature(XmlFeatures.VALIDATION.uri(),
true);
>
>
parserConfiguration.setFeature(XmlFeatures.VALIDATION_SCHEMA.uri(),
> true);
>
parserConfiguration.setFeature(XmlFeatures.SCHEMA_FULL_CHECKING.uri(),
> true);
>
parserConfiguration.setFeature(XmlFeatures.HONOUR_ALL_SCHEMA_LOCATIONS
> .uri(), true);
>
parserConfiguration.setFeature(XmlFeatures.STANDARD_URI_CONFORMANT
> .uri(), true);
>
> parserConfiguration.parse(new XMLInputSource(null,
schemaPath, null));
>
> this.parser = new SAXParser(parserConfiguration);
> }
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> For additional commands, e-mail: j-users-h...@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-users-h...@xerces.apache.org