0% found this document useful (0 votes)
17 views6 pages

XML Trees and DTD Examples

The document contains multiple XML code snippets along with their corresponding Document Type Definitions (DTDs). Each snippet represents different structures such as a bookstore, a meal combo, an address book, and a ship order, among others. The XML trees and DTDs define the elements, attributes, and their relationships within the data.

Uploaded by

ashefikir01
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)
17 views6 pages

XML Trees and DTD Examples

The document contains multiple XML code snippets along with their corresponding Document Type Definitions (DTDs). Each snippet represents different structures such as a bookstore, a meal combo, an address book, and a ship order, among others. The XML trees and DTDs define the elements, attributes, and their relationships within the data.

Uploaded by

ashefikir01
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

1.

Draw xml tree for the following xml Exercises:


<?xml version="1.0"?>
<!DOCTYPE bookstore [
<!ELEMENT bookstore (name,topic+)>
<!ELEMENT topic (name,book*)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT book (title,author)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST book ISBN CDATA "0">
]>
<bookstore>
<name>Mike's Store</name>
<topic>
<name>XML</name>
<book ISBN="120-90-100">
<title> A complete Guide To XML</title>
<author>Mike Jervis</author>
</book>
</topic>
</bookstore>

2. Draw xml tree for the following xml coded and DTD

<?xml version="1.0"?>
<!DOCTYPE Combomeal[
<!ELEMENT Combomeal (burger,fries,drink)>
<!ENTITY COLA "Pepsi" >
<!ELEMENT burger(name,bun)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT bun (meat,cheese,chick)>
<!ATTLIST bun bread (white|wheat) #REQUIRED>
<!ELEMENT meat EMPTY>
<!ELEMENT cheese EMPTY>
<!ELEMENT chick EMPTY>
<!ELEMENT fries EMPTY>
<!ATTLIST fries size (small|medium|large) #REQUIRED>
<!ELEMENT drink (#PCDATA)>
<!ATTLIST drink size (small|medium|large) #REQUIRED>

<Combomeal>
<burger>
<name>Cheeseburger</name>
<bun bread="wheat">
<meat/>
<cheese/>
<cheese/>
</bun>
</burger>
<fries size="large"/>
<drink size="medium">Pepsi</drink>
</Combomeal>

3. Draw xml tree and DTD for the following xml code
<?xml version = "1.0" encoding="UTF-8" standalone="yes" ?>
<addressbook>
<emp1>
<name>Karthick</name>
<doorno>No-2/57</doorno>
<street>Vinayakam St</street>
<area>Teynampet</area>
<city>Chennai-600020</city>
<state>Tamil Nadu</state>
<country>India</country>
<phoneno>909583625</phoneno>
</emp1>
<emp2>
<name>Murali</name>
<doorno>No-25/7</doorno>
<street>ParthasarathyKoil Street</street>
<area>Triplecane</area>
<city>Chennai-600005</city>
<state>Tamil Nadu</state>
<country>India</country>
<phoneno>9962589632</phoneno>
</emp2>
<emp3>
<name>Jagagish</name>
<doorno>No-25</doorno>
<street>Palani Street,</street>
<area>Manali</area>
<city>Chennai-600055</city>
<state>Tamil Nadu</state>
<country>India</country>
<phoneno>9003862541</phoneno>
</emp3>
</addressbook>
<!ATTLIST isbn number CDATA #REQUIRED>
]>

4. Draw xml tree and DTD for the following xml code
<books>
<book>
<title name="C"></title>
<isbn number="2309"></isbn>
<zipcode zname="23244345345"></zipcode>
<publish year="1998"></publish>
</book>
<book>
<title name="C++"></title>
<isbn number="2310"></isbn>
<zipcode zname="45814845585"></zipcode>
<publish year="1995"></publish>
</book>
<book>
<title name="JAVA"></title>
<isbn number="2311"></isbn>
<zipcode zname="553378845585"></zipcode>
<publish year="1995"></publish>
</book>
<book>
<title name="PUZZLES"></title>
<isbn number="2313"></isbn>
<zipcode zname="456644445"></zipcode>
<publish year="1995"></publish>
</book>
<book>
<title name="XML"></title>
<isbn number="2312"></isbn>
<zipcode zname="412684895585"></zipcode>
<publish year="1995"></publish>
</book>
</books>
5. Draw xml tree and DTD for the following xml code

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


<shiporder orderid="889923">
<orderperson>John Smith</orderperson>
<shipto>
<name>Karthick</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>5</quantity>
<price>9.90</price>
</item>
</shiporder>
6. Draw xml tree and DTD for the following xml code

<bookdb>
<book>
<name>Java Complete Reference</name>
<author>lan</author>
<year>2001</year>
<publication>Tata McDraw Hill</publication>
</book>
<book>
<name>C# Complete Reference</name>
<author>balagurusamy</author>
<year>2006</year>
<publication>Persion Addition</publication>
</book>
<book>
<name>Complete Reference</name>
<author>Kanithkar</author>
<year>2005</year>
<publication>Tata McDraw Hill</publication>
</book>
</bookdb>
7. Draw xml tree and DTD for the following xml code

<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>
<book genre="autobiography" pubdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" pubdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" pubdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>

8. Draw xml tree and DTD for the following xml code

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


<person>
<name>
<firstname>John</firstname>
<lastname>Ten,</lastname>
</name>
<occupation>Analyst,</occupation>
<address>
<street>Street 05</street>
<suburb></suburb>
<city>CityLake</city>
<province>Middle Region,</province>
<postalcode>909890,</postalcode>
<country>XYZ,</country>
</address>
<hobbies>
<hobby>Playing football,</hobby>
<hobby>dancing,</hobby>
<hobby>coding!</hobby>
</hobbies>
</person>
9. Draw xml tree and DTD for the following xml code
Use your own sample data for the siblings(last element)

You might also like