• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation with JAXP and XML Schema

 
Shane Semanek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to validate an XML document with an XML Schema using JAXP. The JAXP 1.2 samples show the following code to accomplish this:

final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";

//create and configure SAX parser factory
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);

//create and configure SAX parser
SAXParser saxParser = spf.newSAXParser();
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File(schemaSource));

//parse XML document
saxParser.parse(new InputSource(xmlURI), myDefaultHandler);

However, I would like to use the default Crimson parser that ships with J2SE 1.4. Is there a way to accomplish this using the default Crimson parser that only support JAXP 1.1?

Also, is there a place where all the JAXP parser properties, like http://java.sun.com/xml/jaxp/properties/schemaSource, are listed?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this thread to the XML forum. Please continue this discussion there. Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic