Você está na página 1de 2

CSC570 XML PROGRAMMING

Lab 9 (XML Schema)

XML file: shiporder.xml:

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

<shiporder orderid="st889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">

<orderperson>John Smith</orderperson>
<orderdate>2015-12-27</orderdate>
<trackcode>CS2001</trackcode>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note stock=”yes”>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>4</quantity>
<price>9.90</price>
</item>
</shiporder>

QUESTION 1

Based on the XML file, create a validating XSD file – “shiporder.xsd”. Please bare in-mind
some elements must conform to specific patterns:

a) The "item" element can appears multiple times, but “shipto” element only one time.
b) “shipto” child elements can appear in any order but “item” child elements must appear in
order.
c) “note” element is optional, but if included -- the attribute “stock” is required.
d) Attribute “stock” value must be between “yes” or “no”
e) Attribute “orderid” under “shiporder” element is required
f) Restriction for “trackcode” value: it should have totally 6 characters in which the first 2 are
uppercase alphabets and the remaining 4 are numbers.
g) Restriction for “quantity” value: only accept integer value 1 to 100.
h) Data type for “price” is decimal and “orderdate” is date
QUESTION 2

Modify “shiporder.xml” to make a reference to external DTD file “shiporder.dtd”. Save as


“shiporderdtd.xml”. Create a validating DTD file “shiporder.dtd” that conform to the
requirement:

a) The "item" element can appears multiple times, but “shipto” element only one time.
b) “note” element is optional, but if included -- the attribute “stock” is required.
c) Attribute “stock” value must be between “yes” or “no”
d) Attribute “orderid” under “shiporder” element is required

Submit all your files (shiporder.xml, shiporderdtd.xml, shiporder.xsd & shiporder.dtd) to


aliffaisalibrahim@gmail.com using the following as subject/title:

(Lab 9/studID1 & studID2/Group)

Submission date: 13/12/2017 (Group B), 17/12/2017 (Group A) before midnight. Late
submission will not be accepted.

Você também pode gostar