cancel
Showing results for 
Search instead for 
Did you mean: 

Error while trying to validate XML against XSD

Former Member
0 Kudos

I am trying to validate an XML against an XSD using SAX.

I have the following code:

SAXParserFactory factory = SAXParserFactory.newInstance();

factory.setValidating(true);

factory.setNamespaceAware(true);

SAXParser saxParser = factory.newSAXParser();

saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");

When I run this, I get a SAXNotRecognizedException: Property: http://java.sun.com/xml/jaxp/properties/schemaLanguage

Do I have to set a classpath or import any external libraries?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I found the solution to this problem. You have to include the following jar files in your build path:

xercesImpl.jar

xmlParserAPIs.jar

Also if you are trying to set the schema location property, do not use:

http://java.sun.com/xml/jaxp/properties/schemaSource

Instead use:

http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation

Otherwise, you will get another SAXNotRecognizedException.

Too bad I can't award myself points lol.

Edited by: Michael Morala on Jan 22, 2009 8:00 PM