I am stucked in getting my xml validated through an xsd
I am getting exception when i am executing my code to validate
xml
against
an xsd
Error:-----
org.jdom.JDOMException:
http://apache.org/xml/properties/schema/external-noNamespaceSchem aLocation
property not
recognized for SAX driver org.apache.xerces.parsers.SAXParser
at
org.jdom.input.SAXBuilder.internalSetProperty(SAXBuilder.java:751
)at
org.jdom.input.SAXBuilder.setFeaturesAndProperties(SAXBuilder.jav
a:678)
at
org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:528)
at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:424)at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)at
XMLValidator.validateSchema(XMLValidator.java:39)at
XMLValidator.main(XMLValidator.java:85)
My Code:-----------
public class XMLValidator {
public void validateSchema(
String SchemaUrl, String
XmlDocumentUrl) {
try {
SAXBuilder saxBuilder = new
SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
saxBuilder.setValidation(true);
saxBuilder.setFeature(
"http://apache.org/xml/features/validation/schema", true);
/*error error in this
line*/saxBuilder.setFeature("http://apache.org/xml/features/valid
ation/schema-full-checking"
,true);
saxBuilder.setProperty("http://apache.org/xml/properties/schema/e
xternal-noNamespaceSchemaLo
cation",SchemaUrl); /* error in this line */
................
saxBuilder.build(XmlDocumentUrl);
/*throwing exception here
external-noNamespaceSchemaLocation property not recognized for
SAX
driver
org.apache.xerces.parsers.SAXParser*/
......................
public static void main(String[] argv) {
.............
}
}
-----------------------------------------------------------------
---------------
This is xml format i am creating using jdom parser:-----
<?xml version="1.0" encoding="UTF-8"?>
<cdm>
<report><R_id>1237</Rentity_id><code>India</code><R_code>STR</R_c
ode>
.......
</cdm>
This is xsd:--------------------------------------------
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Cdm">
<xs:include schemaLocation="goNums.xsd"/>
<xs:element name="Cdm">
<xs:complexType>......................................
Please do reply
Regards
Zia
[email protected]