Day 4. Creating Valid XML Documents: DTDs

The past couple days have prepared you for what's coming up now—the creation of valid XML documents. Unlike with HTML, where a browser can check HTML because it knows all about legal HTML, you create your own markup in XML, which means that an XML processor can't check your markup unless you let it know how to. In XML, you define what's legal and what's not by specifying the syntax you're going to allow for an XML document. There are two ways to validate XML documents—with document type definitions (DTDs) and with XML schemas. Today and tomorrow cover DTDs, and Days 6, "Creating Valid XML Documents: XML Schemas," and 7, "Creating Your Own Types in XML Schemas," cover XML schemas.

Here's an overview of today's topics:

  • Creating DTDs
  • Using validators
  • Declaring elements
  • Using ANY to allow any content
  • Declaring child elements
  • Declaring parsed character data
  • Creating child sequences
  • Using DTD choices
  • Using internal and external DTDs
  • Using DTDs and namespaces

DTDs provided the original way to validate XML documents, and the syntax for DTDs is built right in to the XML 1.0 specification. Tons of XML processors out there use DTDs in XML documents, and DTDs are the first step in any discussion on validation. But it's also true that DTDs are limited compared to XML schemas, and with the vast support Microsoft is pouring into XML schemas, schemas are really taking off these days. The details on schemas are provided on Days 6 and 7.

Share ThisShare This