Starting from:

$30

Project 3  DTD D1 for project/employee documents

CSE 462: Project 3 
You are given the following XML document (doc1.xml):
<?xml version="1.0" encoding="UTF-8"?
<projects
<project pid="p123"
<leader
<nameAmanda</name
</leader
<analyst
<nameBob</name
</analyst
</project
<project pid="p456"
<leader
<nameJohn</name
</leader
</project
<project pid="p789"
<leader
<nameDavid</name
</leader
<analyst
<nameAmanda</name
</analyst
</project
</projects
Problem 1
Write a DTD D1 for project/employee documents, enforcing the following constraints:
• Each project is identified by a unique pid.
• Each project involves one or more employees.
• There are only two roles: leader and analyst.
• Each project has at least one leader.
• The first employee listed in a project is always a leader.
The document doc1.xml should be valid with respect to the DTD D1.
Problem 2
Write an XQUERY script that transforms documents valid with respect to the DTD D1 to a
format in which projects involving an employee are listed under this employee. In particular,
the document doc1.xml should be transformed into the following document (doc2.xml):
<?xml version="1.0" encoding="UTF-8"?
<workforce
<emp roles="leader,analyst" name="Amanda"
<projects
<projp123</proj
<projp789</proj
</projects
</emp
<emp roles="analyst" name="Bob"
<projects
<projp123</proj
</projects
</emp
<emp roles="leader" name="David"
<projects
<projp789</proj
</projects
</emp
<emp roles="leader" name="John"
<projects
<projp456</proj
</projects
</emp
</workforce
Note: you have to make sure that employees are listed in alphabetical order.
Problem 3
Write a DTD for doc2.xml.
Problem 4
Write an XQUERY script that will extract from doc1.xml all the projects that have no
analysts. The output should be formatted as follows:
<?xml version="1.0" encoding="UTF-8"?
<noanalysts
<pidp456</pid
</noanalysts
Submission rules
Test your XQuery code with http://www.xpathtester.com/xquery. Test your DTDs
with http://www.validome.org/xml/validate/. If your code does not work with these
websites, it will not be graded. Please embed the DTDs in the original xml files, as discussed in class. Please submit four distinct files: Project3 P1.xml, Project3 P2.xquery,
Project3 P3.xml and Project3 P4.xquery.
You should submit your work using submit cse462.

More products