W3C_XML_SCHEMA_NS_URI); // load a WXS schema, represented by a Schema instance Source schema File = new Stream Source(new File("my Schema.xsd")); Schema schema = Schema(schema File); // create a Validator instance, which can be used to validate an instance document Validator validator = Validator(); // validate the DOM tree try catch (SAXException e) on a parser factory.The former technique will cause parsers to use the new validation API; the latter will cause parsers to use their own internal validation facilities.This section looks at the process of XML Schema validation.Although a full treatment of XML Schema is beyond the scope of this tutorial, this section shows you the steps you take to validate an XML document using an XML Schema definition.
These are the same constants you define when using XML Schema for SAX parsing, and they are declared at the beginning of the Because JAXP-compliant parsers are not namespace-aware by default, it is necessary to set the property for schema validation to work.
To report errors, it is necessary to provide an Error Handler to the underlying implementation.
The Error Handler used for the examples is a very simple one which reports the error to and continues until the XML document has been fully parsed or until a fatal-error has been reported.
Sun's JDK 6 uses SAX parser with a Stream Source.
@ziggy - this is an implementation detail of the JAXP implementation.
) as defined below has been used in the code examples to validate the input document.