The validation cannot be robust if it depends on the content of the document, such as JAXP uses URIs as identifiers for properties and attributes, which is consistent with the use of URIs as namespace identifiers.
If your parser is not JAXP 1.2-compliant, it throws a object that simply prints validation errors on the console, as shown in Listing 3.
Your application could register a more interesting handler, such as one that does something with the document content.
Once an instance of this class is obtained, XML can be parsed from a variety of input sources.
These input sources are Input Streams, Files, URLs, and SAX Input Sources.
The detailed procedure is: When implementing robust validations with XML schemas, keep in mind that -- almost by definition -- when your application validates documents, it should not depend on those documents being correct.
It enables you to quickly check that input is roughly in the form you expect and quickly reject any document that is too far away from what your process can handle.
(This description is painted with broad strokes -- there are exceptions.)Until recently, the exact Application Programming Interface (API) by which programs requested validation varied with the schema language and parser.
DTDs and XSD were normally accessed as configuration options in Simple API for XML (SAX), Document Object Model (DOM), and Java™ API for XML Processing (JAXP). Schematron might use the Transformations API for XML(Tr AX); and still other schema languages required programmers to learn still more APIs, even though they were performing essentially the same operation.
Validating is useful -- after all, what's the point in processing documents if the application does not recognize the elements?