• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

PROBLEM IN VALIDATING XML AGAINST AN XSD

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any particular reason to use JDOM? Java 1.5 has the javax.xml.validation package in the standard library.

Bill
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic