XML - Managing Data Exchange/The one-to-many relationship/Answers
Chapter
editTo return to the chapter, follow this link: One-to-many relationship
Exercises
editTo view the exercises, follow this link: exercises
Answer - Exercise 1
editXML schema:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
XML document:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
Answer - Exercise 2
edit
XML schema:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
XML document:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
Answer - Exercise 3
editXML schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified">
<!-- Spa Finder -->
<xsd:element name="spaFinder">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="spa" type="spaDetails" minOccurs="1"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<!-- Spa -->
<xsd:complexType name="spaDetails">
<xsd:sequence>
<xsd:element name="spaName" type="xsd:string"/>
<xsd:element name="spaOwner" type="xsd:string"/>
<xsd:element name="spaPhone" type="xsd:string"/>
<xsd:element name="spaCity" type="xsd:string"/>
<xsd:element name="spaState" type="xsd:string"/>
<xsd:element name="spaAddress" type="xsd:string"/>
<xsd:element name="startedIn" type="xsd:date"/>
<xsd:element name="spaType" type="xsd:string"/>
<!--Activity is a complexType defined in the Spa to
indicate the one-to-many relationship between spa and activities.-->
<xsd:element name="activity" type="activityDetails" minOccurs="1"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- Activity -->
<xsd:complexType name="activityDetails">
<xsd:sequence>
<xsd:element name="activityName" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
<xsd:element name="price" type="xsd:decimal" />
<!--Offering is a complexType defined in the Activities to
indicate the one-to-many relationship between activities and offerings.-->
<xsd:element name="offering" type="offeringDetails" minOccurs="1"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- Offering -->
<xsd:complexType name="offeringDetails">
<xsd:sequence>
<xsd:element name="days" type="xsd:string"/>
<xsd:element name="time" type="xsd:string"/>
<xsd:element name="practitioner" type="xsd:string" />
<xsd:element name="floor" type="xsd:integer"/>
<xsd:element name="room" type="xsd:string" />
</xsd:sequence>
</xsd:complexType></xsd:schema>
Exercises
editTo view the exercises, follow this link: exercises