Validate XML file using JAXP(SAX Parser) with XSD schema
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Soni_K
Posted On:   Tuesday, December 2, 2003 03:11 AM

I am trying to use the SAX parsers provide in Java programming (JAXP). I am trying to set the schemaLanguage and schemaSource Properties. The problem lies with schemaSource is not being recognised. it throws the following errors org.xml.sax.SAXNotRecognizedException: http://java.sun.com/xml/jaxp/properties/schemaSource at org.apache.xerces.parsers.AbstractSAXParser.setProperty(AbstractSAXParser.java:1691) at org.apache.xerces.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:205) at testPack.TestClass.main(TestClass.java:56) The code is as follows DefaultHandler handler = new TestClass(); SAXParserFactory factory = SAXParserFactory.newInstance();    More>>

I am trying to use the SAX parsers provide in Java programming (JAXP). I am trying to set the schemaLanguage and schemaSource Properties. The problem lies with schemaSource is not being recognised. it throws the following errors

			
org.xml.sax.SAXNotRecognizedException: http://java.sun.com/xml/jaxp/properties/schemaSource


at org.apache.xerces.parsers.AbstractSAXParser.setProperty(AbstractSAXParser.java:1691)

at org.apache.xerces.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:205)

at testPack.TestClass.main(TestClass.java:56)


The code is as follows
			
DefaultHandler handler = new TestClass();
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");
saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource","C:\Program Files\App1\App1.xsd");


   <<Less

Re: Validate XML file using JAXP(SAX Parser) with XSD schema

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, December 2, 2003 08:48 AM

Make sure you are actually loading from the right version of the SAX parser Jar; older ones don't know how to validate against XML Schemas.

About | Sitemap | Contact