Document type definitions
Thursday, 1-3 </item> </list> <paragraph> We hope you can join us. </paragraph> <closing> Sincerely, S. R. Ranganathan </closing> </letter>
By feeding this XML to an XML processor, the XML processor should know that the element named letter is the root of the XML file, and the XML file can be validated using a local, non-standardized DTD file named letter.dtd.
Exercise - Writing a simple DTD
In this exercise your knowledge of DTDs will be sharpened by examining an existing DTD, and then you will write your own DTD.
Consider the DTD describing the content of the catalog.xml file, below, and on the back of this pa- per write the answers the following questions:
(caption, structure, work+)> (#PCDATA)> (title, author, type, date)> (title, author, type, date)> (#PCDATA)> (#PCDATA)> (#PCDATA)> (#PCDATA)>
How many elements can the catalog element contain, and what are they?
How many works can any one catalog.xml file contain?
Can marked up text be included in the title element? Explain why or why not.
If this DTD is intended to be a locally developed DTD, and intended to be accessed from out- side the XML document, how would you write the DTD declaration appearing in the XML file?
Create an internal DTD for the file ala.xml, and validate the resulting XML file.
Open ala.xml in NotePad.
Add an internal document type declaration to the top of the file, <!DOCTYPE letter [ ]>.
Between the square brackets (), enter the beginings of an element declaration for each ele-