You are on page 1of 4

ITL-226: Web Systems & Technologies Lab

Semester BS (IT) – 05
HASSAN RAZA
02-235201-022

Lab 8 Introduction to XML

Exercise 1

For the given xml tree create an xml document, and DTD. In a separate file.

XML:
<? xml version = "1.0" encoding = "utf-8"
standalone = "no" ?>
<!---- this is an employee coment-->
<document > Book
<title>Charlotte's Web</title>
<abstract>Story Book</abstract>
<chapter>Play1
<title>Scene1</title>
<section>
<title>Scene2</title>
<p>Talking</p>
<p>watching<a>T.v</a></p>
<p>Cycling</p>
<p>jumping</p>
</section>
<section>section2</section>
</chapter>
<chapter> chapt2</chapter>
<chapter>chapter3</chapter>
</document>

DTD:
<? xml version = “1.0” >

Department of Computer Sciences 1/4 Semester BSIT 05


ITL-226: Web Systems & Technologies Lab Lab 08: Introduction to xml
ITL-226: Web Systems & Technologies Lab
Semester BS (IT) – 05
HASSAN RAZA
02-235201-022

<!DOCTYPE doc [

<!ELEMENT doc
(title,abstract,chapter,chapter,chapter)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT abstract (#PCDATA)>
<!ELEMENT chapter
(title,section,section)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT section (title,p,p,p,p)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT p (#PCDATA)>
<!ELEMENT p (a)>
<!ELEMENT a (#PCDATA)>
<!ELEMENT p (#PCDATA)>
<!ELEMENT p (#PCDATA)>
<!ELEMENT section (#PCDATA)>
<!ELEMENT chapter (#PCDATA)>
<!ELEMENT chapter (#PCDATA)>
]>

Exercise 2
For the following xml tree create the xml document, DTD of the same tree and xml schema for the same document.
Add DTD externally in the xml file.

Department of Computer Sciences 2/4 Semester BSIT 05


ITL-226: Web Systems & Technologies Lab Lab 08: Introduction to xml
ITL-226: Web Systems & Technologies Lab
Semester BS (IT) – 05
HASSAN RAZA
02-235201-022

XML:
<!DOCTYPE anthology SYSTEM
"anosha.dtd">
<anthology>
<poem1>
<title> Still I Rise</title>
<stanza1>
<line1>You may write me down in history
</line1>
<line2> With your bitter, twisted lies,
</line2>
<line3> You may trod me in the very dirt
</line3>
<line4>You may trod me in the very dirt
</line4>
</stanza1>
<stanza2>
<line5> Does my sassiness upset you? </line5>
<line6> Why are you beset with gloom?
</line6>
<line7>'Cause I walk like I've got oil
wells</line7>
<line8> Pumping in my living room. </line8>
</stanza2>
</poem1>
<poem2>
<title> The Tiger</title>
<stanza1>
<line1> Tiger! Tiger! burning bright </line1>
<line2>In the forest of the night
</line2>
<line3> What immortal hand or eye
</line3>
<line4> Could frame thy fearful symmetry?
</line4>
</stanza1>
</poem2>
</anthology>

Department of Computer Sciences 3/4 Semester BSIT 05


ITL-226: Web Systems & Technologies Lab Lab 08: Introduction to xml
ITL-226: Web Systems & Technologies Lab
Semester BS (IT) – 05
HASSAN RAZA
02-235201-022

DTD:
<? xml version = “1.0” >
<!DOCTYPE anthology [
<!ELEMENT anthology (poem1, poem2)>
<!ELEMENT poem1 (title, stanza1, stanza2)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT stanza1 (line1, line2, line3,
line4)>
<!ELEMENT line1 (#PCDATA)>
<!ELEMENT line2 (#PCDATA)>
<!ELEMENT line3 (#PCDATA)>
<!ELEMENT line4 (#PCDATA)>
<!ELEMENT stanza2 (line5, line6, line7,
line8)>
<!ELEMENT line5 (#PCDATA)>
<!ELEMENT line6 (#PCDATA)>
<!ELEMENT line7 (#PCDATA)>
<!ELEMENT line8 (#PCDATA)>
<!ELEMENT poem2 (title, stanza )>
<!ELEMENT title (#PCDATA)>
<!ELEMENT stanza1 (line1, line2, line3,
line4)>
<!ELEMENT line1 (#PCDATA)>
<!ELEMENT line2 (#PCDATA)>
<!ELEMENT line3 (#PCDATA)>
<!ELEMENT line4 (#PCDATA)>
]>

Department of Computer Sciences 4/4 Semester BSIT 05


ITL-226: Web Systems & Technologies Lab Lab 08: Introduction to xml

You might also like