SAXParser is recommended if SAX parsing event notification is required in addition to validation with a schema.
DOMParser is recommended if the DOM tree structure of an XML document is required for random access and modification of the XML document.
uses the non-validating parser by default, but it can also activate validation.
This section examines the validating parser to find out what happens when you use it to parse the sample program.
In this section we shall validate the example XML document with XML schema document catalog.xsd, with the SAXParser class. Create a SAXParser object and set the validation mode of the SAXParser object to SCHEMA_VALIDATION, as shown in the following listing: Validates the complete XML document with an XML schema if the parser is able to find a schema.
If the parser is not able find a schema or if the XML document does not conform to the schema, an error is raised.
Create an XSDBuilder object and invoke the build(Input Source) method of the XSDBuilder object to obtain an XMLSchema object.
The Input Source object is created with an Input Stream object created from the example XML schema document,