Validity

Programmers have long known the value of verifiable preconditions on functions and methods. (A lot of us carelessly don't use them, but that's a topic for another book.) One of the important innovations of XML is the ability to place preconditions on the data the programs read, and to do this in a simple declarative way. XML allows you to say that every Order element must contain exactly one Customer element; that each Customer element must have an id attribute that contains an XML name token; that every ShipTo element must contain one or more Streets, one City, one State, and one Zip; and so forth. Checking an XML document against this list of conditions is called validation. Validation is an optional step but an important one.

There ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.