Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1324 What is the advantage of having DTD in an xml document?

You are here: irt.org | FAQ | XML | Q1324 [ previous next ]

The reason why you want to include DTD's in XML documents, is that the DTD is a vocabulary of the XML elements that you use.

For example consider the below simple XML document:

<product>
        <description>Danish shoes</description>
        <size>41</size>
        <price>42.45$</price>
</product>

In this case the DTD would contain the following elements: product, description, size, and prize

The DTD then lets you do validation in your XML document (are you using 'allowed' elements), and it also describes what kind of element for example the price element is (e.g. is it PCDATA?).

Last, but not least, there is currently work going on at the W3C on schemas, which is planned to replace DTD's in the near future.

©2018 Martin Webb