IT462 Lab 11: XML
The purpose of this assignment is to familiarize you with using XML for storing and querying data. For this assignment, you will create the DTD for a given XML file and then write XPath and XQuery queries to answers some questions.
Preliminaries:
On your X drive, inside your IT462 folder, create a folder named "Lab11"
(without quotes). All your work for this lab should be inside Lab11 directory.
Create a yourlastname_Lab11.doc file that contains your answers for the lab
exercises.
Download the Kernow zip file from the course calendar to your Desktop and unzip it. We will use Kernow to run XPath and XQuery queries. To start the program, you should double-click on the Kernow.exe file from Kernow 1.7.2 folder.
In this lab, you are working with a sample data set about
world countries. Download the countries.xml file
into your Kernow 1.7.2 folder. This data is adapted
from the Mondial 3.0 database as hosted by the University
of Washington. Each country has a name, population, and area (in km˛). Some
countries also list languages (with percentages of the population that speaks
each language) and/or cities (with names and populations).
Part 1: Create a DTD
Write a DTD that is valid with respect to the data in
countries.xml file. The easiest way of doing it is to modify the countries.xml
file to add and internal DTD (similar with the Bookstore example shown in class).
Validate your coutries.xml file against the DTD you created by using the W3C Markup Validation Service at validator.w3.org. If you have an external DTD, you can use “More Options” link on the validator page to upload the DTD.
Copy-paste the DTD definition created to
yourlastname_Lab11.doc file
Copy-paste a print screen of the first page
of the validator as run on your countries.xml (and
DTD if external) to yourlastname_Lab11.doc file.
Part 2: XPath
As mentioned in the Preliminaries, we will use Kernow to execute XPath and XQuery queries. Start Kernow.exe and select the XQuery sandbox tab. You will write your queries there.
Write XPath queries to answer the following questions (one query for each question below). Execute the XPath queries using Kernow to ensure you get the correct answer.
Copy-paste each XPath
query to yourlastname_Lab11.doc file.
Answer on the sample data:
<language percentage="18">French</language>
<language percentage="65">German</language>
<language percentage="12">Italian</language>
<language percentage="1">Romansch</language>
Answer on the sample data:
1565000
Answer on the sample data:
Bangladesh Brazil China India Indonesia Japan Nigeria Pakistan Russia United States
Answer on the sample data:
6
Answer on the sample data:
Austria Germany Switzerland
Part 3: XQuery
Write XQuery queries to answer the following questions (one query for each question below). Execute the XQuery queries in Kernow to ensure you get the correct answer.
Copy-paste each XQuery
query to yourlastname_Lab11.doc file.
Start of the answer on the sample
data:
Afghanistan Albania Algeria American Samoa Andorra Angola Anguilla Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia Bosnia and Herzegovina Botswana Brazil British Virgin Islands Brunei
Answer on the sample data:
Bangladesh Brazil China India Indonesia Japan Nigeria Pakistan Russia United States
Start of the answer on the sample
data:
<country_info>Afghanistan, 22664136</country_info>
<country_info>Albania, 3249136</country_info>
<country_info>Algeria, 29183032</country_info>
<country_info>American Samoa, 59566</country_info>
<country_info>Andorra, 72766</country_info>
<country_info>Angola, 10342899</country_info>
Turn in (Both
electronic and paper submissions are required):
Electronic:
Hard-copies: