Assignment Question XML Schema and XML Document Programming

Description of assessment task.

XML Schema and XML Document Programming

1 Introduction

This ACW will create XML schemas to describe one or multiple XML documents, and create

multiple XML documents from one XML schema using Visual Studio(VS) . The ACW will also

create a HTML file to inlclude XML files and XML schemas using VS or other web page

development tools. The first three exercises are creating XML schemas from XML documents. The

second three exercises are creating XML documents using schemas. The last exercise is creating

a html page to include XML files and schemas. There are seven exercises totally.

2 Tasks

2.1 Creating XML schemas from XML documents

A schema is an XML document that describes the structure of another XML document. A

schema can be used to check that an XML document has the required structure. Create

schemas for following XML documents.

07/10/2020

4

Exercise 1

Create a schema to describe the following XML document

<orders>

<orderItem>

<item>washer</item>

<code>4352</code>

<quantity>100</quantity>

<cost>23.6</cost>

</orderItem>

<orderItem>

<item>nut</item>

<code>4372</code>

<quantity>100</quantity>

<cost>55.6</cost>

</orderItem>

<customer>Acme Engineering</customer>

<totalCost>79.12</totalCost>

</orders>

Exceice 2

Create a schema to describe both of the following XML documents.

<addresses>

<address>

<houseNo>Usher</houseNo>

<street>High</street>

<city>Hull</city>

</address>

</addresses>

<addresses>

<address>

<street>High</street>

<city>Hull</city>

</address>

<address>

<street>High</street>

<city>Hull</city> <postCode>HU1 2ER</postCode>

</address>

</addresses>

Exceice 3

Create a schema to describe three of the following XML documents.

<addresses>

</addresses>

<addresses>

<address>

<city>Hull</city>

<street>Low</street>

<postCode>HU6 7RX</postCode>

</address>

</addresses>

<addresses>

<address>

<city>Hull</city>

<street>Low</street>

<postCode>HU6 7RX</postCode>

</address>

<address>

<street>High</street>

<city>Hull</city>

<postCode>HU1 2ER</postCode>

</address>

</addresses>

07/10/2020

5

2.2 Creating XML documents using schemas

Exercise 4

Given the following XML schema for an invoice, create a valid XML document

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="invoice">

<xs:complexType>

<xs:sequence>

<xs:element maxOccurs="unbounded" minOccurs="1" name="dept"

type="deptType"/>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:complexType name="deptType">

<xs:sequence>

XML Schema and XML Document Programming

<xs:element name="deptnum" type="xs:string"/>

<xs:element name="deptname" type="xs:string"/>

<xs:element name="deptaddress" type="xs:string"/>

<xs:element name="deptlimit" type="xs:integer"/>

<xs:element maxOccurs="unbounded" minOccurs="1" name="deptstatement"

type="accountType"/> </xs:sequence>

</xs:complexType>

<xs:complexType name="accountType">

<xs:sequence>

<xs:element name="accountid" type="xs:integer"/>

<xs:element name="accountdate" type="xs:date"/>

<xs:element maxOccurs="unbounded" minOccurs="0" name="accountcharge"

type="chargeType"/> </xs:sequence>

</xs:complexType>

<xs:complexType name="chargeType">

<xs:sequence>

<xs:element name="chargeid" type="xs:string"/>

<xs:element name="chargeamount" type="xs:decimal"/>

<xs:element name="chargedate" type="xs:date"/>

</xs:sequence>

</xs:complexType>

</xs:schema>

Exercise 5

Given the following XML schema for a statement, create two valid XML

documents.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="statement">

<xs:complexType>

<xs:sequence>

<xs:element maxOccurs="unbounded" minOccurs="1" name="dept"

type="deptType"/>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:complexType name="deptType">

<xs:sequence>

<xs:element name="deptID" type="xs:string"/>

<xs:element name="deptname" type="xs:string"/>

<xs:element name="deptlimit" type="limitType"/>

<xs:element maxOccurs="unbounded" minOccurs="1" name="deptstatement"

type="transType"/> </xs:sequence>

</xs:complexType>

<xs:element name="limit" type="limitType" />

<xs:simpleType name="limitType">

<xs:restriction base="xs:integer">

<xs:minInclusive value="0"/>

<xs:maxInclusive value="100"/>

07/10/2020

6

</xs:restriction>

</xs:simpleType>

<xs:complexType name="transType">

<xs:sequence>

<xs:element name="item" type="xs:integer"/>

<xs:element name="date" type="xs:date"/>

<xs:element maxOccurs="unbounded" minOccurs="2" name="charge"

type="xs:decimal"/> </xs:sequence>

</xs:complexType>

</xs:schema>

Exercise 6

Given the following XML schema for a statement, create three valid XML documents.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="car">

<xs:complexType>

<xs:all>

<xs:element name="drive" type="xs:unsignedByte" />

<xs:element name="colour" type="xs:string" fixed="red"/>

<xs:element name="class" type="xs:string" />

<xs:element name="engine">

<xs:complexType>

<xs:sequence>

<xs:element name="size" type="xs:unsignedShort" />

<xs:element name="fuel">

<xs:complexType>

<xs:choice>

<xs:element name="petrol"/> <xs:element name="diesel"/>

</xs:choice>

</xs:complexType>

</xs:element> </xs:sequence>

</xs:complexType>

</xs:element>

</xs:all>

</xs:complexType>

</xs:element>

</xs:schema>

2.3 Creating a html page to include XML files and schemas

Exercise 7

Create one html file to include all the original and generated XML schemas and XML documents for all the above exercises.

3 Submissions

Upload one .zip file to Canvas including the followings:

Original and generated Visual Studio XML file(s) and XML schema file(s) for exercises 1-6. One html file including all the original and generated XML schemas and XML documents for

exercises 1-6.

Make sure that your XML files and XML schemas works and match each other. Make sure that your web pages can be correctly displayed on different browsers (e.g Internet Explorer or Google

Chrome). Do not submit files in any other archive format than .zip.


Do you want answer for this assignment