File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Validation with JAXP and XML Schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Validation with JAXP and XML Schema" Watch "Validation with JAXP and XML Schema" New topic
Author

Validation with JAXP and XML Schema

Shane Semanek
Greenhorn

Joined: Jun 24, 2004
Posts: 4
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

Joined: Aug 26, 2001
Posts: 7610
Moving this thread to the XML forum. Please continue this discussion there. Thank you


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation with JAXP and XML Schema
 
Similar Threads
Validation with JAXP and XML Schema
problem with validating sax parser
SAXParser not Validating
Schema Validation
Problem validating schema