X hits on this document

546 views

0 shares

1 downloads

0 comments

27 / 142

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.

1.

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:

<!ELEMENT

catalog

<!ELEMENT

caption

<!ELEMENT

structure

<!ELEMENT

work

<!ELEMENT

title

<!ELEMENT

author

<!ELEMENT

type

<!ELEMENT date

(caption, structure, work+)> (#PCDATA)> (title, author, type, date)> (title, author, type, date)> (#PCDATA)> (#PCDATA)> (#PCDATA)> (#PCDATA)>

A.

How many elements can the catalog element contain, and what are they?

B.

How many works can any one catalog.xml file contain?

C.

Can marked up text be included in the title element? Explain why or why not.

D.

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.

A.

Open ala.xml in NotePad.

B.

Add an internal document type declaration to the top of the file, <!DOCTYPE letter [ ]>.

C.

Between the square brackets ([]), enter the beginings of an element declaration for each ele-

2.

19

Document info
Document views546
Page views552
Page last viewedThu Jan 19 22:16:53 UTC 2017
Pages142
Paragraphs3126
Words34660

Comments