XML - Managing Data Exchange/ Recursive relationships (Answers)

realy.xsd (XML schema for exercise 1)

edit
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" 
    attributeFormDefault="unqualified">
    <xsd:element name="relay">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="runner" type="runnerType" 
                    maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
        </xsd:element>
    <xsd:complexType name="runnerType">
        <xsd:sequence>
            <xsd:element name="runnerID" type="xsd:ID"/>
            <xsd:element name="runnerName" type="xsd:string"/>
            <xsd:element name="previousRunner" type="xsd:IDREF" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>
 

relay.xml(XML document for exercise 1)

edit
<?xml version="1.0" encoding="UTF-8"?>
<relay xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xsi:noNamespaceSchemaLocation='relay.xsd'>
<runner>
    <runnerID>c1</runnerID>
    <runnerName>Tom</runnerName>     
</runner>
<runner>
    <runnerID>c2</runnerID>
    <runnerName>Jim</runnerName> 
    <previousRunner>c1</previousRunner >      
</runner>
<runner>
    <runnerID>c3</runnerID>
    <runnerName>Scott</runnerName> 
    <previousRunner>c2</previousRunner >      
</runner>
<runner>
    <runnerID>c4</runnerID>
    <runnerName>George</runnerName> 
    <previousRunner>c3</previousRunner >      
</runner>
</relay> 


sales.xsd(XML schema for exercise 2)

edit
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified">
    <xsd:element name="sales">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="salesPerson" type="salesType" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:complexType name="salesType">
        <xsd:sequence>
            <xsd:element name="sPersonID" type="xsd:ID"/>
            <xsd:element name="sPersonName" type="xsd:string"/>
	<xsd:element name="sPersonState" type="xsd:string"/>
	<xsd:element name="sPersonRegion" type="xsd:string"/>
            <xsd:element name="sPersonBoss" type="sPtype" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="sPtype">
        <xsd:sequence>
            <xsd:element name="Boss" type="xsd:IDREF"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>
 

sales.xml(XML document for exercise 2)

edit
<?xml version="1.0" encoding="UTF-8"?>
<sales xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xsi:noNamespaceSchemaLocation='sales.xsd'>
<salesPerson>
    <sPersonID>c1</sPersonID>
    <sPersonName>Tommy Jones</sPersonName>
    <sPersonState>GA</sPersonState>
    <sPersonState>North</sPersonState>
    <sPersonBoss>
	<Boss>c3</Boss>
    </sPersonBoss>
</salesPerson>
<salesPerson>
    <sPersonID>c2</sPersonID>
    <sPersonName>Tim Jack</sPersonName>
    <sPersonState>GA</sPersonState>
    <sPersonState>North</sPersonState>
    <sPersonBoss>
	<Boss>c3</Boss>
    </sPersonBoss>
</salesPerson>
<salesPerson>
    <sPersonID>c3</sPersonID>
    <sPersonName>Fred Vick</sPersonName>
    <sPersonState>GA</sPersonState>
    <sPersonState>North</sPersonState>
</salesPerson>
<salesPerson>
    <sPersonID>c4</sPersonID>
    <sPersonName>Rob Looker</sPersonName>
    <sPersonState>SC</sPersonState>
    <sPersonState>East</sPersonState>
    <sPersonBoss>
	<Boss>c6</Boss>
    </sPersonBoss>
</salesPerson>
<salesPerson>
    <sPersonID>c5</sPersonID>
    <sPersonName>Scott Nook</sPersonName>
    <sPersonState>SC</sPersonState>
    <sPersonState>East</sPersonState>
    <sPersonBoss>
	<Boss>c6</Boss>
    </sPersonBoss>
</salesPerson>
<salesPerson>
    <sPersonID>c6</sPersonID>
    <sPersonName>Andrew Ingle</sPersonName>
    <sPersonState>SC</sPersonState>
    <sPersonState>East</sPersonState>
</salesPerson>
</sales>

food.xsd(XML schema for exercise 3)

edit
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified">
    <xsd:element name="food">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="appetizer" type="aType" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:complexType name="aType">
        <xsd:sequence>
            <xsd:element name="aID" type="xsd:ID"/>
            <xsd:element name="aName" type="xsd:string"/>
            <xsd:element name="aPrice" type="xsd:decimal" minOccurs="0"/>
            <xsd:element name="includes" type="includedType" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="includedType">
        <xsd:sequence>
            <xsd:element name="included" type="xsd:IDREF"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema> 

food.xml(XML document for exercise 3)

edit
<?xml version="1.0" encoding="UTF-8"?>
<food xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xsi:noNamespaceSchemaLocation= food.xsd'>
<appetizer>
    <aID>a1</acID>
    <aName>Chips and dip</acName>
    <aPrice>2.99</acPrice>
</appetizer>
<appetizer>
    <acID>a2</acID>
    <acName>Salad</acName>
    <acPrice>3.99</acPrice>
</appetizer>
<appetizer>
    <acID>a3</acID>
    <acName>Wings</acName>
    <acPrice>6.99</acPrice>
</appetizer>
<appetizer>
    <acID>a4</acID>
    <acName>Bread</acName>
    <acPrice>4.99</acPrice>
</appetizer>
<appetizer>
    <acID>a5</acID>
    <acName>Big Plate</acName>
    <acPrice>6.99</acPrice>
    <acTime>24</acTime>
    <includes>
    <included>a2</included>   
    </includes>
    <includes>
    <included>a4</included>    
    </includes>
</appetizer>
<appetizer>
    <acID>a6</acID>
    <acName>Party Plate</acName>
    <acPrice>10.99</acPrice>
    <includes>
    <included>a3</included>   
    </includes>
    <includes>
    <included>a1</included>    
    </includes>
</appetizer>
</food>