In this article you will learn to work with Document Type Definitions or DTDs. These allow you to validate your XML documents which are well-formed. XML document descriptions (which is what DTDs and Schemas are), are statements that decide how content can/must appear in your XML documents. The document descriptions are read by software and then your document is checked against this description to ensure that all of the rules are followed.
In our previous article we learned how to create well-formed XML documents, and learned the rules to ensure we created them properly. We also touched further upon the hierarchy structure of the parent, child, and sibling scheme.
About Document Descriptions
Document descriptions are a form of metadata because they contain data that helps to describe other data. Below is a list of data you can expect to find in your document descriptions:
Some description of the elements that exist in your document.
A description of the kind of content that your elements can have.
The order in which your elements can/must appear in your document.
A range that element attribute values must contain or content values elements must have.
How many times an element may occur.
A guide to the relationships of the various elements that exist in your document.
In short, these metadata or definitions hold the rules for describing your data, and not the actual data itself.
Should You Create a Document Description?
Here is a list of reasons why you might wish to create a document description. It is not mandatory to do so by any means, so take these reasons into consideration when deciding if you should create one or not:
If you need to specify certain types of content not available somewhere else.
If you want to have a set of rules for your document and have the ability to ensure those rules are being followed. Your document description makes this an automated task.
If you have definitive data to collect, store, or organize.
You wish to create a new industry standard.
If the data you collect is unwieldy or complicated.
You probably should not use a document description if the following applies to you:
There is already a document description that fits your needs.
If you only have a single or simple document, there is no need to complicate matters with a document description.
If you are working with a relatively small and simple amount of data.