6 XML DTD

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

IS515 Information Modeling

XML DTD and XPath Activity

XML DTD Generation and XPath queries

Learning Objectives
● To gain experience creating a DTD file from a relational schema description and writing XPath queries.

Prerequisite
Students have reviewed the course material on XML and tree data models.
`
IS515 Information Modeling
XML DTD and XPath Activity

Constraints about the Schema


● Leagues have one of three types: men’s, women’s, or co-rec.
● Leagues consist of one or more divisions, each based on a regular time and place for matches.
● Each team belongs to a league division.
● Matches are either “season” play or “playoff”.
● In addition to match score, each team is given a sportsmanship rating from 0-4 for their conduct during the game.
● Team members may have the role “captain” or “player”.

Group What
Whole class Overview & instructions
Groups meet in their own room Create a DTD file conforming to the constraints.

Whole class Discuss DTD files.


Groups meet in their own room Write XPath queries.

Whole class Discuss XPath queries.

Group number: _2___


Write your names below:
● ..
● ..
● Wanpeng
● ..

Generate a DTD definition for the relational schema, taking into account the constraints above.
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE Tournament [
<!ELEMENT League "(League_Name, League_Type);">
<!ATTLIST League"
League_Type #REQUIRED">
IS515 Information Modeling
XML DTD and XPath Activity

<!ELEMENT League_Name (#PCDATA)>

<!ELEMENT Division"(League_Name, Division_Name, Match_Place, Day_of_Week, Match_Time);">


<!ATTLIST Division_Name"
Team #REQUIRED">
<!ELEMENT League_Name (#PCDATA)>
<!ELEMENT Match_Place (#PCDATA)>
<!ELEMENT Day_of_Week (#PCDATA)>
<!ELEMENT Match_Time (#PCDATA)>

<!ELEMENT Team "(Team_Name, Division_Name);">


<!ATTLIST Team"
Team_Name #REQUIRED">
<!ELEMENT Division_Name (#PCDATA)>

<!ELEMENT Schedule "(Team_Name, Division_Name);">


<!ATTLIST Match_ID"
Match_ID #REQUIRED">
<!ELEMENT Division (#PCDATA)>
<!ELEMENT Match_Type (#PCDATA)>
<!ELEMENT Date (#PCDATA)>
<!ELEMENT Team (#PCDATA)>
<!ELEMENT Team_Score (#PCDATA)>
<!ELEMENT Team_Sportsmanship (#PCDATA)>

<!ELEMENT Roster "(Team, Player_Name, Gender, Role, Enrollment data);">


<!ATTLIST Roster"
Team #REQUIRED">
<!ATTLIST Roster"
Player_Name #REQUIRED">
<!ELEMENT Gender (#PCDATA)>
<!ELEMENT Role (#PCDATA)>
IS515 Information Modeling
XML DTD and XPath Activity

<!ELEMENT Enrollment_Date (#PCDATA)>

<!ELEMENT (#PCDATA)>
<!ENTITY writer "Writer: Group 3.">
<!ENTITY copyright "">
]>

Write XPath expressions to retrieve the following information:


● Players of the team ‘Chambana Moms’
● Teams playing in women’s leagues
● Teams playing playoff games

//Team[@TeamName=”Chambana Moms”]/Players

/League[@Type=”women”]//Team

/Schedule[@Type=”playoff”]/(TeamA | TeamB)

You might also like