Zoo tutorials: [ SQL | Java | Linux | XML ]

A Gentle Introduction to xml

Allowing options
With answers

We wish to enforce the following rules:

Change the xsd so that the xml on the left passes validation and the xml on the right fails validation.

Options

Schema


XML input

ValidInvalid
<country>
  <name>United Kingdom</name>
  <monarch>Elizabeth II</monarch>
</country>
<country>
  <name>Ruritania</name>
  <monarch>Rudolf</monarch>
  <monarch>Michael</monarch>
  <monarch>Rudolf</monarch>
  <!--Should not allow three monarchs -->
</country>
<country>
  <name>France</name>
  <president>Sarkozy</president>
</country>
<country>
  <name>Ruritania</name>
  <president>Robert</president>
  <monarch>Rudolf</monarch>
  <!-- Cannot have president and monarch-->
</country>
<country>
  <name>Norway</name>
  <monarch>Harald</monarch>
</country>
<country>
  <name>Ruritania</name>
  <!-- Should have president or monarch-->
</country>