You are on page 1of 4

CSC570

Lab 3 (DTD)

1) XML with correct syntax is a well- formed XML. For each of the following XML, state
whether or not it is well- formed. Explain all violations if it is NOT a well- formed XML.
[June 2013]
2) A Document Type Definition (DTD) defines the legal building blocks of an XML
document. It defines the document structure with a list of legal elements and attributes.

a. Copy the XML above inside XML editor and validate the xml to make s ure that it
is a well-formed xml. (notice that single quote, ', is also allowed)
b. Write an INTERNAL DTD for the XML document. Try to validate the XML
using your DTD.

3) Write an external Document Type Definition (DTD) named schedule.dtd for the XML
data with the structure shown in Figure 3 and its specification, given below:

XML structure:
The above structure is based on the following specification:

o SCHEDULE must contain a single DATE followed by one or more SHOW and
STATION.
o SHOW must have an attribute of SHOW_SLOT with the value of 'MORNING' or
'NOON' or 'EVENING' or 'PRIME' or 'NIGHT'.
o SHOW must contain a single SHOW_NAME, EPISODE_NO, once or more
instance of ACTOR and atrribute TYPE.
o ACTOR must have a FIRST_NAME followed by zero or more MIDDLE_NAME,
and a SURNAME element.
o DATE, STATION, SHOW_NAME and names of ACTOR are in text.
o EPISODE_NO is in number.
o TYPE must have the value of either 'DOCUMENTARY' or 'COMEDY or
'DRAMA' or 'NEWS' or 'SPORT.

Validate this XML using your written DTD:

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE SCHEDULE SYSTEM "schedule.dtd">
<SCHEDULE>
<DATE>15/10/2013</DATE>
<SHOW SHOW_SLOT="PRIME" TYPE="DOCUMENTARY">
<SHOW_NAME>Michael Jackson</SHOW_NAME>
<EPISODE_NO>1</EPISODE_NO>
<ACTOR>
<FIRST_NAME>Michael</FIRST_NAME>
<SURNAME>Jackson</SURNAME>
</ACTOR>
</SHOW>
<SHOW SHOW_SLOT="PRIME" TYPE="COMEDY">
<SHOW_NAME>LAWAK KE DER</SHOW_NAME>
<EPISODE_NO>2</EPISODE_NO>
<ACTOR>
<FIRST_NAME>Jep</FIRST_NAME>
<SURNAME>Sepah2</SURNAME>
</ACTOR>
<ACTOR>
<FIRST_NAME>Syuib</FIRST_NAME>
<SURNAME>Sepah2</SURNAME>
</ACTOR>
</SHOW>
<STATION>TV3</STATION>
</SCHEDULE
4) Consider the following XML document, where
- Every section element must have exactly one headline sub-element,
- Every ul element must have between 2 and 3 li sub-elements.

a. Copy the XML above inside XML editor and validate the xml to make sure that it
is a well-formed xml.
b. Write an EXTERNAL DTD for the XML document. Try to validate the XML
using your DTD. Remember to define/include the DTD file inside your XML file.
i. Put <!DOCTYPE form SYSTEM "form.dtd"> inside the XML

You might also like