You are on page 1of 2

University of Laghouat Semi-Structured Data

Department of computer science academic year: 2023/2024


3rd year License Lab Exercise 1: introduction to XML

Exercise 1:
1. Give an xml document (by not using attributes), which includes the
information that the first name of a person is Lakhdar, his last name is
Kachna, and his professions are computer scientist, mathematician, and
cryptographer.
2. Modify the document given in question1, such the first and the last are
the attributes of the name element.

Exercise 2:
Create a well-formed XML document containing details of a car like: id,
company name, model, engine and mileage.

Exercise 3:
1. Check well-formedness property for the following XML document and
state the reasons in case of not well formed:

<?xml version="1.0"?>
<!-- this is a note -->
<note date=3 janvier>
<to>Bob</To>
<from>Alice</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note date="january 5" <!-- this is another note --> >
<to>Alice</to>
<from>Bob
<body>No problem & see you soon</body>
</note>
<note />

2. Correct the following XML document to be well-formed (hint: use the XML
editor):

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


<movies>
<movie id=”56225”>
<title>Love Story</title>
<title></title>
<year>1980</year>
<_director name='Coppola'></_director>
<comment text="Five start” text=”Average"/>
<xml>Introduce XML content</xml>
<newcomment text="An <important> text">Oscar</newcomment>
<comment lang=de>&copy; 1980 Warner Bros.</comment>
<!-- Famous movie of the --80s -->
</Movie>
</movies>

-1-
University of Laghouat Semi-Structured Data
Department of computer science academic year: 2023/2024
3rd year License Lab Exercise 1: introduction to XML
Exercise 4: Given the XML document below, What are the namespaces of
each attribute and element:

<category xmlns="http://macollection.com">
<name >
Category <em xmlns="http://www.w3.org/1999/xhtml">A</em>
</name>
<category>
<name >B</name>
<category xmlns:xhtml="http://www.w3.org/1999/xhtml">
<name ><xhtml:em >C</xhtml:em></name>
</category>
</category>
<coll:category xmlns="http://www.w3.org/1999/xhtml"
xmlns:coll="http://macollection.com">
<coll:name ><b >D</b></coll:name>
<category >
<coll:name >E</coll:name>
</category>
</coll:category>
</category>

Exercise 5 :
1. Correct the mistakes in the following (not well-formed) XML document:
<?xml version="1.0"?>
<?DOCTYPE "eth" SYSTEM "eth.dtd"?>
<eth xmlns="http://www.ethz.ch"
xmlns:xmldb="http://www.dbis.ethz.ch"
date="11.11.2006"
xmldb:date="12.11.2006">
<date>13.11.2006</date>
<president number="1">Empty<president>
<Rektor>Name 2</rektor>
</Doc>

2. What are the namespaces of each attribute and element?

-2-

You might also like