Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Polytechnic School of Algiers 2023-2024

Specialty: Data Science and Artificial Intelligence, 1st year, S2


Course: Advanced Database

Tutorial# 7: Semi-structured data (XML)

Exercise 1:
Given the file: student.xml

<?xml version = "1.0"?>


<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>
<class>
<student rollno = "393">
<firstname>Dinkar</firstname>
<lastname>Kad</lastname>
<nickname>Dinkar</nickname>
<marks>85</marks>
</student>
<student rollno = "493">
<firstname>Vaneet</firstname>
……………
……………
</class>
a) What is the XPath expression that select the document root
b) Use the XPath expression that select all element under root node.
c) Use the XPath expression that select all student nodes
d) Use the XPath expression that select the student node who’s the rollno=”493”

Exercise 2:
1. In XSLT, based on the following XML document:
<sports>
<game id = "783">
<name>Cricket</name>
<paragraph>
More popular among commonwealth nations.
</paragraph>
</game>
<game id = "239">
<name>Baseball</name>
………
………
</sports>

a) What is the XSL element that select the document root


b) What is the XSL element that retrieve the game id attribute value

2. Write the following XML element by using an attribute


<book>
<title>Learn XML</title>
</book>

3. What are the categories of types used in XML schema documents, and what is the difference
between them.

4. What is the main purpose of XML and what are the main differences with XHTML

5. Transform the following XML element by adding the namespace: xmlns:image =


"urn:deitel:imageInfo"

< file filename = "funny.jpg">


Tutorial: Semi-structured DB (XML) Dr. Hakim Fourar-Laidi
<description>A funny picture</description>
<size width = "200" height = "100" />
</file>

6. Which techniques are used by an XML parser to verify whether an XML document is valid

7. Write the XPath expressions


a) that locates and retrieve title nodes in the following XML document
b) Retrieve the author who’s the name is equal to “john”

<?xml version = "1.0"?>


<article>
<title>Simple XML</title>
<date>July 4, 2007</date>
<author>
<firstName>John</firstName>
<lastName>Doe</lastName>
</author>
<summary>XML is pretty easy.</summary>
<content>This chapter presents examples that use XML.</content>
</article>

8. Write an XML document example based on the following DTD


<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>

9. Based on the following XML document


<person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>
Fill the XML Schema associated bellow
<element ……………………………=……………………………………… type=……………………………………>
<complexType …………………………………… = …………………………………………………>
<sequence>
<element ………………………=……………………… type=…………………………………………/>
<element ………………………=……………………… type=…………………………………………/>
</sequence>
</complexType>

-2-

You might also like