wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes PROBLEM IN VALIDATING XML AGAINST AN XSD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "PROBLEM IN VALIDATING XML AGAINST AN XSD" Watch "PROBLEM IN VALIDATING XML AGAINST AN XSD" New topic
Author

PROBLEM IN VALIDATING XML AGAINST AN XSD

zia uddin
Greenhorn

Joined: Apr 30, 2007
Posts: 4
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
zia.uddin@yahoo.co.in
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
Is there any particular reason to use JDOM? Java 1.5 has the javax.xml.validation package in the standard library.

Bill
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
first of all: why are you shouting at us (->subject)?

as the preview post says, validation is included already in standard api. i am quite content with it. have a look at my code snippet. it should show you how it works.


aldana software engineering blog & .more
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: PROBLEM IN VALIDATING XML AGAINST AN XSD
 
Similar Threads
JDOM Exception - Urgent
javax.xml.validation doubt!
feature not recognized for SAX driver parser.XMLReaderI
Validate against schema
building error when validating against schema using jdom