[jdom-interest] Using schema from a Jar file

Laurent Bihanic laurent.bihanic at atosorigin.com
Wed Apr 2 07:55:35 PST 2003


CNjaka at ndsamericas.com wrote:
> I am developing an application that will need to use and validate XML
> configuration files. I'd like the config files to not only be well-formed,
> but to conform to a schema. The schema will be deployed with the application
> in a JAR file. The question is, how can I let the parser know (I plan to use
> Xerces) where the schema in within the JAR file? Is the property
> "external-noNamespaceSchemaLocation" limited to a string?

You can get a valid JAR URL by retrieving the schema through the classloader:

URL schemaUrl = this.getClass().getClassloader().getResource(schemaPath);

Xerces should accept schemaUrl.toString() as a valid URL for 
external-noNamespaceSchemaLocation.

Laurent




More information about the jdom-interest mailing list