Just before we start parsing the XML document, we specify the XML Schema file by using the set Attribute(JAXP_SCHEMA_SOURCE,...) of the factory. * */ public class XMLSchema Validator What we do here is simply parsing an XML document. We request the Document Builder Factory to validate a given XML document against a given XML Schema document by invoking the set Validate() method of the factory.
Parser Configuration Exception; /* * This is an XML Schema validator written in Java.
This package is also available in Java 1.3 and later when you install JAXP 1.3 separately.
Among other products, an implementation of this library is included with Xerces 2.8. If you validate in multiple threads simultaneously, make sure each one has its own However, normally this isn't what you want.
By comparison, with a SAX parser you have to know exactly what you're looking for at the time you parse.
Useful if you're unmarshalling JAXB objects or extracting data from a large file, not so useful if you're exploring a data structure.