validate org.w3c.dom.Element against xsd
595832Sep 18 2007 — edited Sep 21 2007I 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