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

A Gentle Introduction to xml

Payment problem

Customers at the till may pay with a combination of credit cards and cash.

Make up a schema so that the XML on the left passes validation but the XML on the right fails validation. The schema given is too permissive - it allows any combination of card and cash.

Payment problem

Schema


XML input

ValidInvalid
<payment>
  <card/>
  <cash/>
</payment>
<payment>
  <cash/>
  <cash/>
  <!-- two cash payments -->
</payment>
<payment>
  <cash/>
</payment>
<payment>
  <!-- no payment at all -->
</payment>
<payment>
  <card/>
</payment>
<payment>
  <cash/>
  <card/>
  <!-- cash before card -->
</payment>