Validating and non validating parser difference
Just the other day I got an email from a user asking if it was possible to use Code Synthesis XSD with a light-weight XML parser that he found instead of Xerces-C .Out of curiosity I checked the parser’s description and there I saw a number of common traits of most new, fast, and small XML parsers these days: no support for DTD (internal subset) and CDATA sections, limited support for character and entity references.Because JAXP-compliant parsers are not namespace-aware by default, it is necessary to set the property for schema validation to work.The last step is to configure the parser to tell it which schema language to use.For now, think of these attributes as the "magic incantation" you use to validate a simple XML file that doesn't use them.After you've learned more about namespaces, you'll see how to use XML Schema to validate complex documents that use them.You can get away with using a non-conforming XML parser if you control the production of XML you are planning to parse and thus restrict the set of XML constructs that can appear in your documents. If you control both the production and consumption of the data then you might as well choose a more natural (for your application and environment) and efficient (that’s why choose this new parser) exchange format than XML.A more common scenario is when you have to parse XML supplied by various third parties and once you say your format is XML then all bets are off; it is only a matter of time before someone sends you a perfectly valid XML document that your application won’t be able to handle.
(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.
Here, you use the constants you defined earlier to specify the W3C's XML Schema language: In the process, however, there is an extra error to handle. In addition to the error handling you've already learned about, there is one error that can occur when you are configuring the parser for schema-based validation.
If the parser is not 1.2-compliant and therefore does not support XML Schema, it can throw a Note: You'll learn about namespaces in Validating with XML Schema.
It's time to have a look at the validating parser to find out what happens when you use it to parse the sample presentation.
You need to understand about two things about the validating parser at the outset: .