Skip to Main Content

Java Development Tools

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!

validate org.w3c.dom.Element against xsd

595832Sep 18 2007 — edited Sep 21 2007
I need to validate a org.w3c.dom.Element against an xsd.

DOMParser dp = new DOMParser();
URL xmlurl = new URL("file:\\test.xml");
XSDBuilder builder = new XSDBuilder();
URL xsdurl = new URL("file:\\test.xsd");
XMLSchema schemadoc = (XMLSchema)builder.build(xsdurl);
dp.setXMLSchema(schemadoc);
dp.setValidationMode(XMLParser.SCHEMA_LAX_VALIDATION);
dp.setPreserveWhitespace(true);
dp.setErrorStream (System.out);
System.out.println("Parsing "+xmlurl);
dp.parse(xmlurl);

This works when my input is an xml file. I cannot get it work against an element. If I convert the element as a string or inputsource it gives the error
"XML-20220: (Fatal Error) Invalid InputSource.
java.net.MalformedURLException: no protocol:"

Any idea how it can be done? I am using jdeveloper 10.1.2

Thanks
MM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 19 2007
Added on Sep 18 2007
15 comments
1,807 views