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

A Gentle Introduction to xml

minOccurs and maxOccurs
With answers

Rule to be enforced:

Fix this by adding minOccurs and maxOccurs attributes on the xs:element tags. We can use the value unbounded if there is no maximum.

Options

Schema


XML input

ValidInvalid
<module>
  <name>XML 3</name>
  <teacher>Andrew</teacher>
  <prerequisite>Programming 2</prerequisite>
</module>
<module>
  <name>XML5</name>
  <!-- no teacher -->
  <prerequisite>XML 3</prerequisite>
  <prerequisite>Web Scripts 3</prerequisite>
</module>
<module>
  <name>Database 2</name>
  <teacher>Andrew</teacher>
  <teacher>Ken</teacher>
</module>
<module>
  <name>XML3</name>
  <name>IML3</name>
  <!-- Two names -->
  <teacher>Ken</teacher>
  <prerequisite>XML 3</prerequisite>
  <prerequisite>Web Scripts 3</prerequisite>
</module>
<module>
  <name>XML4</name>
  <teacher>Ken</teacher>
  <prerequisite>XML 3</prerequisite>
  <prerequisite>Web Scripts 3</prerequisite>
</module>
<module>
  <name>XML3</name>
  <teacher>Andrew</teacher>
  <room>A17</room>
  <!-- no such node allowed -->
</module>