• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

DTDs and Validation

The DTD describes a model of the structure of the content of an XML document. This model says what elements must be present, which are optional, what their attributes are, and how they can be structured in relation to each other. Although HTML has only one DTD, XML enables you to create your own DTDs for your applications, which gives you complete control over the process of checking the content and structure of the XML documents created for that application. This checking process is called validation. Depending on what you, as the DTD developer, want to achieve, you can exercise almost complete control over the structure and create a strict DTD. When you validate XML documents that were created using this strict DTD, you can insist that certain elements be present, and you can enforce the set order you require. You can check that certain attribute values have been set and, to a limited degree, you can even check that these attribute values are of the right general type.

On the other hand, you can also make almost everything optional and create a loose DTD. You could even have parallel versions of the same DTD, one that enables you to create draft versions of the XML that aren't complete and another that rigidly checks that everything is present. It is even possible to insert switches into a DTD that can be used to turn the degree of strictness on and off.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint