You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Fuller, Alex" <Al...@Lodestarcorp.com> on 2004/03/24 22:41:49 UTC
Grammar Caching and XMLErrorHandlers
Hi All,
I've been working on using grammar caching code a little different
than the example code shows. I haven't come across this in the
archives, so I thought I'd see if I'm just not using the objects as
intended. I'm running Xerces 2.4.0.
Here's the sample code:
public SchemaValidator(String uri) throws InitializationException
{
this.parserConfig = new XMLGrammarCachingConfiguration();
this.parserConfig.setErrorHandler(this);
this.parserConfig.parseGrammar(XMLGrammarDescription.XML_SCHEMA,
new XMLInputSource(null, uri, null));
this.parser = new SAXParser(this.parserConfig);
try
{
// Don't know if I still have to set these
this.parser.setFeature("http://xml.org/sax/features/validation",
true);
this.parser.setFeature("http://apache.org/xml/features/validation/schema
", true);
}
catch (SAXException e)
{
throw new InitializationException(e);
}
}
My problem is that when the schema cannot be found or there is a problem
loading it, I get a message like the following on the error stream:
[Warning] TransCollection.xsd:6:77: src-import.0: Failed to read
imported schema document 'schema_file.xsd'.
The error is supposed to happen, but I was hoping to trap it. Any
ideas? Does the ErrorHandler not apply here? When I try to set the
error handler as a property, it throws an exception.
Thanks,
Alex
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org