Zoo tutorials: [ SQL | Linux | XML ]

A Gentle Introduction to xml

Batches
With answers

Another puzzle. This one looks at sequences of debit and credit transctions.

A batch consists of a number of debits followed by a number of credits.

Change the DTD so that the XML on the left passes validation but the XML on the right fails validation.


ValidInvalid
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE batch SYSTEM "batch.dtd">
<batch>
  <debit/>
  <credit/>
</batch>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE batch SYSTEM "batch.dtd">
<batch>
  <debit/>
  <debit/>
  <credit/>
  <credit/>
</batch>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE batch SYSTEM "batch.dtd">
<batch>
  <debit/>
  <debit/>
  <credit/>
</batch>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE batch SYSTEM "batch.dtd">
<batch>
</batch>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE batch SYSTEM "batch.dtd">
<batch>
  <debit/>
  <credit/>
  <credit/>
</batch>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE batch SYSTEM "batch.dtd">
<batch>
  <credit/>
  <debit/>
</batch>