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

A Gentle Introduction to xml

Specifying child nodes

Rules to be enforced

The sequence can contain elements. Each element node may have minOccurs set.

The xsd given is fine for the United Kingdom and Norway but it does not suit France.

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

Names, Capitals, Kings and Queens

Schema


XML input

ValidInvalid
<country>
  <name>United Kingdom</name>
  <capital>London</capital>
  <queen>Elizabeth II</queen>
</country>
<country>
  <name>Ruritania</name>
  <capital>Strelsau</capital>
  <king>Rudolf</king>
  <king>Michael</king>
  <king>Rudolf</king>
  <!--Should not allow three kings -->
</country>
<country>
  <name>France</name>
  <capital>Paris</capital>
</country>
<country>
  <name>Ruritania</name>
  <king>Rudolf</king>
  <!-- capital is missing-->
</country>
<country>
  <name>Norway</name>
  <capital>Oslo</capital>
  <king>Harald</king>
  <queen>Sonja</queen>
</country>
<country>
  <capital>Strelsau</capital>
  <!-- name is missing -->
</country>