Hi,
I am having an issue validating documents against my schema when
running the application on another machine.
I use the following with schemaUrl containing the URL of the Schema I
want to use, parser being a SAXparser
parser.setFeature("http://xml.org/sax/features/validation",true);
parser.setFeature("http://apache.org/xml/features/
validation/schema",true);
parser.setFeature ("http://apache.org/xml/features/
validation/schema/augment-psvi", true);
parser.setFeature("http://apache.org/xml/features/
validation/schema-full-checking", true);
parser.setProperty("http://apache.org/xml/properties/schema/
external-noNamespaceSchemaLocation", schemaUrl );
parser.setProperty("http://apache.org/xml/properties/schema/
external-schemaLocation", schemaUrl);
I use a local schema file in the same directory as the application,
e.g. my_schema.xsd, then I get the absolute path of the file using
File schemaFile = new File(schemaUrl);
String schemaFileName = new String(schemaFile.getAbsolutePath());
e.g. I get back Users/timbeau/bin/my_schema.xsd on one machine and /
home/bin/my_schema.xsd on another (which is correct as far as I can
tell...).
This works on one machine, but on the another with the same schema
and application it does not, with the validator not finding the
definition for the top/outer level element type and thus not
validating. I suspect this is because the parser is not finding the
schema. If I do not perform the absolute path step, I can also get
the same error on the first machine. Note that the schemas are not
available "online", but are local files.
I have tried with a xsi:schemaLocation in the document and without. I
do not use namespaces.
This is very frustrating as I am deploying the application and it is
refusing to behave!
BTW the application is in a "fat jar" so the Xerces libraries are
bundled inside the jar and consistent as far as I can tell.
Thanks in advance.
Tim