Enforcing XML Document Structure

If XML is used to transfer information between applications, there needs to be a mechanism for ensuring that the XML is not only syntactically correct but also is structurally correct. In fact, there are two common mechanisms for this:

  • Document Type Definitions

  • XML Schemas

DTDs were the original form of validation but could not be manipulated by the same tools (such as JAXP, which is discussed on Day 16) as the XML documents they described. This was seen as a disadvantage of DTDs, and XML Schemas were defined as XML documents that define the structure of other XML documents. And before you ask, yes there is an XML Schema that defines the XML Schema structure (see http://www.w3.org/2001/XMLSchema.xsd); there is ...

Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.