XSD

Solutions

XSD Solutions

1.

a)

<group name="friends">
  <person>John</person>
  <person>Jane</person>
  <person>Mary</person>
  <person>Carl</person>
  <person>David</person>
</group>

b)

<group name="friends" description="a group of friends">
  <person>John</person>
  <person>Jane</person>
  <person>Mary</person>
  <person>Carl</person>
  <person>David</person>
</group>

2.

a)

<matches>
  <match>
    <referee>John Doe</referee>
    <player>Roger Federer</player>
    <player>Novak Djokovic</player>
  </match>
  <match>
    <referee>Jane Doe</referee>
    <player>Rafael Nadal</player>
    <player>Stan Wawrinka</player>
  </match>
  <match>
    <referee>Mary Doe</referee>
    <player>Kei Nishikori</player>
    <player>Andy Murray</player>
  </match>
</matches>

b)

<matches>
  <referee>John Doe</referee>
  <player>Roger Federer</player>
  <player>Novak Djokovic</player>
  <referee>Jane Doe</referee>
  <player>Rafael Nadal</player>
  <player>Stan Wawrinka</player>
  <referee>Mary Doe</referee>
  <player>Kei Nishikori</player>
  <player>Andy Murray</player>
</matches>

c)

<matches>
  <match date="2015-01-01">
    <referee>John Doe</referee>
    <player>Roger Federer</player>
    <player>Novak Djokovic</player>
  </match>
  <match date="2015-01-02">
    <referee>Jane Doe</referee>
    <player>Rafael Nadal</player>
    <player>Stan Wawrinka</player>
  </match>
  <match date="2015-01-03">
    <referee>Mary Doe</referee>
    <player>Kei Nishikori</player>
    <player>Andy Murray</player>
  </match>
</matches>

d)

<matches>
  <match date="2015-01-01">
    <referee name="John Doe"/>
    <player name="Roger Federer"/>
    <player name="Novak Djokovic"/>
  </match>
  <match date="2015-01-02">
    <referee name="Jane Doe"/>
    <player name="Rafael Nadal"/>
    <player name="Stan Wawrinka"/>
  </match>
  <match date="2015-01-03">
    <referee name="Mary Doe"/>
    <player name="Kei Nishikori"/>
    <player name="Andy Murray"/>
  </match>
</matches>

e)

<matches>
  <match date="2015-01-01">
    <referee name="John Doe"/>
    <player name="Roger Federer"/>
    <player name="Novak Djokovic"/>
  </match>
  <match date="2015-01-02">
    <referee name="Jane Doe"/>
    <player name="Rafael Nadal"/>
    <player name="Stan Wawrinka"/>
  </match>
  <match date="2015-01-03">
    <referee name="Mary Doe"/>
    <player name="Kei Nishikori"/>
    <player name="Andy Murray"/>
  </match>
</matches>

3.

<destinations>
  <destination continent="Africa"/>
  <departure>2015-01-01</departure>
  <departure>2015-01-02</departure>
  <price single="100" double="190"/>
  <destination continent="Asia"/>
  <departure>2015-01-03</departure>
  <departure>2015-01-04</departure>
  <price single="80" double="140"/>
</destinations>

4.

<photos>
  <photo size="20x30" src="http://site.pt/foto1.jpg">5</photo>
  <photo size="10x15" src="http://site.pt/foto2.jpg">3</photo>
</photos>

5.

<trips>
  <plane name="Vacations 2015" type="leisure" nr_places="4">
    <place>
      <description>The second-largest city in Portugal</description>
      <href>http://en.wikipedia.org/wiki/Porto</href>
      <date>2015-01-01</date>
    </place>
  </plane>
  <car name="Conference 2015" type="professional" nr_places="2">
    <place>
      <description>Annual Conference on XML</description>
      <href>www.w3.org/XML/</href>
      <date>2015-11-01</date>
    </place>
  </car>
</trips>

6.

<realestate>
  <apartment>
    <salesman>John Doe</salesman>
    <price>200</price>
    <interested name="Carl Doe" contact="111-111-111">Lawyer with 3 daughters</interested>
    <interested name="Mike Doe" contact="222-222-222">Has 3 dogs</interested>
    <interested name="David Doe" contact="333-333-333">Said would call Monday</interested>   
  </apartment>
  <apartment>
    <salesman>Jane Doe</salesman>
    <price>300</price>
    <interested name="Lewis Doe" contact="444-444-444">Doesn't like loud noises</interested>
    <interested name="Joan Doe" contact="555-555-555">Offered more money</interested>
    <interested name="Zack Doe" contact="666-666-666">Would like a private garage</interested>   
  </apartment>
  <house>
    <salesman>Mary Doe</salesman>
    <price>500</price>
    <interested name="Carla Doe" contact="777-777-777">Thinks is too expensive</interested>
    <interested name="Chris Doe" contact="888-888-888">Asked if the TV is staying</interested>
    <interested name="Dana Doe" contact="999-999-999">Wants to demolish and rebuild</interested>   
  </house>
</realestate>

7.