How to Create a Document Type Definition (DTD)
An XML file can have a document type definition or DTD which contains and defines tags which can be used in the XML document. DTD is actually antecedent to XML schema which is generally used now as a way to define elements and attributes which can be used to create an XML document.
Creating a DTD means creating elements, attributes and notations for an XML file which contains reference to the DTD and these elements and attributes will define and control the structure of the DTD.
Firstly, we will discuss the DTD elements. Consider the syntax for element declaration as described below. It is must to write element name and content type here. For example, a student element would be defined as:
<! ATTLIST student subject CDATA “English”>
It is clear
that apart from attribute name, an attribute can have attribute type and
default value. Here type is CDATA which implies that value is character
data and its default value is English. An attribute can also be defined
as required, implied(if its value is not necessary) or fixed. As clear
from the name it is compulsory for a attribute to have value if it is
declared as required.
Now we have gone through the important component of a DTD which further help in structuring an XML document. We can declare the DTD (which would be used in defining the XML document ) inside the document as well as externally.
Also it is
possible to validate an XML document against its corresponding DTD. This
is done by the use of “validateOnParse” property (of Document
object which represents an XML document). It its value is set “true”,
it tells XML parser
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage
| About Runtime Components of .NET Framework | About Session Management in a Web Based Enterprise Application | An introduction to Microsoft Mobile Internet Toolkit (MMIT) | How to Internationalize Your .NET Application | How to Create a Document Type Definition (DTD) | How to Create a .NET Windows Service Easily | Knowing the Difference Between Application Server and Web Server | Understanding Key Advantages of .NET Type System | Understanding Some Basic Language Related Features of C# |