Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 12 2003
Added on Oct 25 2002
18 comments
842 views