In an earlier post, Structured Authoring: Introducing XML, we saw the role XML had to play in structured documentation. Now let us take a look at how the implementation works.
In the post titled Structured Authoring: Defining the Content Structure, we discussed how to go about analysing the content and breaking it up into smaller units. While the content analysis and definition is a pen-and-paper exercise, the content structure has to be defined using technology so that it can be enforced.
This is where the DTD or Schema comes in.
For the purpose of this preliminary discussion, we are going to use DTD and Schema as analogous terms.
What does a DTD do?
A document type definition, or a DTD as it is commonly called, defines the structure of a document. It specifies the document structure in terms of the tags that may can be used in a document, where and when these tags can be used, and the attributes that each of the tags may have.
Every unique document will have its own DTD or Schema. For example, there will be separate DTDs for user manuals, release notes, case studies, and API references.
When an author wishes to create a particular type of document, the author has to base the document on the relevant DTD.
The DTD itself is an XML document and must adhere to all rules of XML.
Validating an XML Document Against the DTD
When a DTD is associated with an XML document, the XML document is compared against the DTD to ensure it is structured as specified by the DTD. This process of comparison is called validation and it is performed by the validating parser.
When the XML document adheres to the structure defined in the DTD, it is said to be valid.
What Happens If an XML Document is Invalid?
When you are in the authoring stage, the XML editor typically warns you that the document is invalid, but you can save the document. However, when you generate the output or process the document in any way, the invalid document will not be processed. This means that, typically, this document is omitted from the output.
So, the DTD is the foundation on which the structured authoring system is built. 🙂
In the next post, we will see a sample DTD and the process of validation.