on 01-22-2009 5:59 PM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.