When you indite HTML with whatever editors, you’ll attending that there is this fantastic distinction cursive crossways the top<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>. While you haw not undergo what it is, it ease serves a purpose, and with XML that distinction of cipher is required to indite a well-formed document.
This distinction is the “Document Type Declaration” that defines the “Dcoument Type Definition” or DTD. In the HTML declaration<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>there are quaternary parts:
- DOCTYPE
this tells the application that this attach is a Document Type Declaration - HTML
the study of the DTD - PUBLIC
the DTD is acquirable publicly - -//W3C//DTD HTML 4.0 Transitional//EN
the actualised DTD utilised for the document, in this housing HTML 4.0 Transitional in English
What is a DTD?
A DTD in an XML or HTML writing provides a itemize of the elements, attributes, comments, notes, and entities contained in the document. It also indicates their relation to digit added within the document. In another words, a DTD is the grammar of an XML or HTML document.
Purpose of a DTD
When using a DTD for an XML writing (including XHTML), the DTD is there to wage scheme for your documents. It is cushy to indite an XML document, but without the DTD, it has no grammar message to the computer. For example, if you become crossways this assets of an XML document:<address>
<street>123 Any Street</street>
<city>Jackson</city> <state>MI</state>
</address>While you would undergo it was an address, you wouldn’t undergo whether it was an come the machine was questionable to create from a database table, if that come was for mailing, and another things. The computer, on the another hand, wouldn’t wager this as anything more than a progress of text. If you viewed it in an XML browser, you strength not intend some errors, but you also wouldn’t intend a rattling engrossing or multipurpose page.
In another articles, we’ll explore the intrinsic excavation of a DTD, and investigate the elements that attain up a DTD. You’ll see what an element, attribute, entity, and writing is and how to ingest them within your possess DTDs. Plus, you’ll see how to feature another DTDs so that you crapper ingest them in your possess XML documents.
Recent Comments