Technical Questions on DTD

Give the main reasons to use DTD?
Some main reasons to use DTD are given Below:
1. Using DTD XML files can write its description into its format.
2. DTD is an most acceptable standard using DTD different group members can interchange data each other.
3. Also, using DTD we can check the validity of our own data and the data that comes from different groups(other persons).
How to declare DTD?

DTD has two types of declarations internal and external.I have given you brief information of internal and external DTD.

1. Internal DTD Declaration : I have given you a syntax using them you can declare internal DTD in our XML file.
Syntax:
<!DOCTYPE root-element [element-declarations]>
Example: Now I used internal DTD in XML file like that,
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Abhi</to>
<from>Sudd</from>
<heading>Message</heading>
<body>Recently R4R given a VoiceBox facility using them you can chat with R4R</body>
</note>
What is DTD?

DTD is stands for Document Type Defintion. We use DTD in XML document to define the legal building blocks.
Using DTD we can also define the structure of an document with name of legal attributes and elements.
When constructing an XML DTD

Every interview session should have at least one trick question. Although possible when using SGML, XML DTDs don't support defining external entity references in attribute values. It's more important for the candidate to respond to this question in a logical way than than the candidate know the somewhat obscure answer.
Give some examples of XML DTDs

Although XML does not require data to be validated against a DTD, many of the benefits of using the technology are derived from being able to validate XML documents against business or technical architecture rules
How do I write my own DTD?
You need to use the XML Declaration Syntax (very simple: declaration keywords begin with <!ELEMENT Shopping-List (Item)+><!ELEMENT Item (#PCDATA)>It says that there shall be an element called Shopping-List and that it shall contain elements called Item: there must be at least one Item (that's the plus sign) but there may be more than one
Can I use XML namespaces in DTDs?

Yes and no.In particular, DTDs can contain qualified names but XML namespace declarations do not apply to DTDs .This has a number of consequences. Because XML namespace declarations do not apply to DTDs:1. There is no way to determine what XML namespace a prefix in a DTD points to. Which means...2. Qualified names in a DTD cannot be mapped to universal names. Which means...3. Element type and attribute declarations in a DTD are expressed in terms of qualified names, not universal names. Which means...4. Validation cannot be redefined in terms of universal names as might be expected