How to add xsd path in XML using Java code
843834Oct 25 2002 — edited Jul 15 2003
Hi,
I m using SAXParser of xerces2.0.jar for XML document validation.
I want my xsd path to be set dynamically using java code.
I had set all possible features .
saxParser.setFeature("http://xml.org/sax/features/validation", true);
saxParser.setFeature("http://xml.org/sax/features/namespaces", true);
saxParser.setFeature("http://apache.org/xml/features/validation/schema", true);
saxParser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
saxParser.setFeature("http://apache.org/xml/features/validation/warn-on-duplicate-attdef",true);
saxParser.setFeature("http://apache.org/xml/features/allow-java-encodings",true);
I had tried setting schema path by setting parser property as follows
strNewSchemaLocation = "http://localhost:7001/schema/MYFILE.xsd";
saxParser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", strNewSchemaLocation);
with this it was giving me en exception.
"http://localhost:7001/schema/MYFILE.xsd" does not contain even no of URIs (null,-1,-1)
So i have changed schema location and introduced a space in between
the namespace and file name.
strNewSchemaLocation = "http://localhost:7001 " + "schema/MYFILE.xsd";
still it doesnt find the schema file ...
can anybody help me out ?
Thanks
Nilesh.