Purchase Solution

Explain: DTD's in XML

Not what you're looking for?

Ask Custom Question

Please discuss the following question: Describe how you would create and declare DTD's in XML.

Purchase this Solution

Solution Summary

In a five page word document, this solution provides ideas to create and declare DTD's in XML.

Solution Preview

** Please see the attached file for the solution **

DTDs can be declared inline in your XML code or they can reference an external file.

This is an example of an internal DTD.

<?xml version="1.0"?>
<!DOCTYPE message [
<!ELEMENT message (to,from,subject,text)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT subject (#PCDATA)>
<!ELEMENT text (#PCDATA)>
]>
<message>
<to>Dave</to>
<from>Susan</from>
<subject>Reminder</subject>
<text>Don't forget to buy milk on the way home.</text>
</message>

Line 2 defines the <message> element as having the four child elements: <to>, <from>, <subject> and <text>.

<!ELEMENT message (to,from,subject,text)>

This line defines the <to> element to be of type PCDATA.

<!ELEMENT to (#PCDATA)>

Here is the same document with an external DTD reference:

<?xml version="1.0"?>
<!DOCTYPE message SYSTEM "message.dtd">
<message>
<to>Dave</to>
<from>Susan</from>
<subject>Reminder</subject>
<text>Don't forget to buy milk on the way home.</text>
</message>

And here is the referenced DTD file. You can open it in Explorer and select View | Source as above.

<?xml version="1.0"?>
<!ELEMENT message (to,from,subject,text)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT subject (#PCDATA)>
<!ELEMENT text (#PCDATA)>

In DTD, elements are declared using an element declaration with the following syntax:

<!ELEMENT element-name (element-content)>

Empty elements
Empty elements use the empty keyword. Move the mouse over the text for additional information.

<!ELEMENT ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.