Schema location confusion 2003-03-31 - By Richard Rowell
I wrote a simple sax parser about a year ago that just runs through XML files for no other purpose then validation of adherance to our schema. This worked great, but recently I have noticed that it only works if the schema files are in CWD. This was not always the case. I noticed today that if I run it from a CWD where the schema is not located I get a warning about one of the files "included" from the schema.
How can I coax the newer versions of Xerces to look for all of the schema files in the the path specified by EXTERNAL_SCHEMA_PATH rather then just pulling in the top level schema file from there and looking for all of the included files in CWD?
Environment: Sun Java SDK 1.4.1 on Linux Xerces-j 2.3.0
The warning I get (/home/richard/dev/java/sax/ was CWD): [Warning] :0:0: File "file:///home/richard/dev/java/sax/sp_complex_types.xsd" not found
The entire schema is located in /home/richard/dev/import_spec. The sp.xsd file includes the sp_complex_types.xsd like so: <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> <xsd:include schemaLocation="sp_complex_types.xsd"/>
Here is how I set up the parser:
private static final String EXTERNAL_SCHEMA_PROPERTY = "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
public static void main (String args[]) throws Exception { String schema_path = "/home/richard/dev/import_spec/sp.xsd"; XMLReader xr = new SAXParser(); MySAXApp handler = new MySAXApp();
xr.setContentHandler(handler); xr.setErrorHandler(handler); xr.setProperty(EXTERNAL_SCHEMA_PROPERTY, schema_path); xr.setFeature("http://xml.org/sax/features/validation",true); xr.setFeature("http://apache.org/xml/features/validation/schema",true); xr.setFeature("http://apache.org/xml/features/validation/schema-full-checking" ,true );
...
-- Richard Rowell <richard@(protected)>
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|