Note - More information about namespaces is included in Validating with XML Schema in Document Object Model.
For now, think of these attributes as the "magic incantation" you use to validate a simple XML file that does not use them.
If the parser is not compliant with the JAXP spec, and therefore does not support XML Schema, it can throw a , which stands for XML Schema instance.
Remember that your application will not generate a validation exception unless you supply an error handler such as the one here.
As mentioned earlier, warnings are generated only when the SAX parser is processing a DTD.
option and providing the name of the schema source file to be used.
It is important to recognize that the only reason an exception is thrown when a file fails validation is as a result of the error-handling code shown in Setting up Error Handling. public void warning(SAXParse Exception spe) throws SAXException public void error(SAXParse Exception spe) throws SAXException public void fatal Error(SAXParse Exception spe) throws SAXException // ...
(If a combination is not supported by a particular implementation, it is required to generate a factory configuration error).
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 existing schema written in the XML Schema language.
To learn more about XML Schema, you can review the online tutorial, XML Schema Part 0: Primer, at
Note - There are multiple schema-definition languages, including RELAX NG, Schematron, and the W3C "XML Schema" standard.
If these exceptions are not thrown, the validation errors are simply ignored.
In general, a SAX parsing error is a validation error, although it can also be generated if the file specifies a version of XML that the parser is not prepared to handle.
(Descriptions of these options, to configure the factory to return a namespace-aware parser.