0% found this document useful (0 votes)
85 views4 pages

Lab 8 Introduction To XML: Exercise 1

This document discusses an XML lab exercise. It provides an example XML document of a book with a title, abstract, and multiple chapters with sections and paragraphs. It also provides the corresponding DTD that defines the element structure and hierarchy. The document then describes a second exercise involving an XML file for an anthology with multiple poems, each with a title and stanzas containing lines. It includes the XML code for the anthology example, as well as the DTD that defines the element tags and structure.

Uploaded by

Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views4 pages

Lab 8 Introduction To XML: Exercise 1

This document discusses an XML lab exercise. It provides an example XML document of a book with a title, abstract, and multiple chapters with sections and paragraphs. It also provides the corresponding DTD that defines the element structure and hierarchy. The document then describes a second exercise involving an XML file for an anthology with multiple poems, each with a title and stanzas containing lines. It includes the XML code for the anthology example, as well as the DTD that defines the element tags and structure.

Uploaded by

Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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