XML
XmlDataSet reads and writes the original, verbose XML dataset document format. It must conform to the following DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT dataset (table+)>
<!ELEMENT table (column*, row*)>
<!ATTLIST table
name CDATA #REQUIRED
>
<!ELEMENT column (#PCDATA)>
<!ELEMENT row (value | null | none)*>
<!ELEMENT value (#PCDATA)>
<!ELEMENT null EMPTY>
<!ELEMENT none EMPTY>XML dataset document sample:
<!DOCTYPE dataset SYSTEM "dataset.dtd">
<dataset>
<table name="TEST_TABLE">
<column>COL0</column>
<column>COL1</column>
<column>COL2</column>
<row>
<value>row 0 col 0</value>
<value>row 0 col 1</value>
<value>row 0 col 2</value>
</row>
<row>
<null/>
<value>row 1 col 1</value>
<null/>
</row>
</table>
<table name="SECOND_TABLE">
<column>COLUMN0</column>
<column>COLUMN1</column>
<row>
<value>row 0 col 0</value>
<value>row 0 col 1</value>
</row>
</table>
<table name='EMPTY_TABLE'>
<column>COLUMN0</column>
<column>COLUMN1</column>
</table>
</dataset>DbUnit always validates against its own bundled copy of the DTD, so the
SYSTEM value above is just a placeholder. To have an external tool, such
as an IDE or xmllint, validate a document against the real DTD, reference
it directly from the GitHub repository instead:
<!DOCTYPE dataset SYSTEM "https://raw.githubusercontent.com/dbunit/dbunit-extension/main/src/main/resources/org/dbunit/dataset/xml/dataset.dtd">
<dataset>
<table name="TEST_TABLE">
<column>COL0</column>
<column>COL1</column>
<row>
<value>row 0 col 0</value>
<null/>
</row>
<row>
<value>row 1 col 0</value>
<none/>
</row>
</table>
</dataset>Compared to Flat XML, this format is self-describing (the columns are explicit per table, rather than deduced from attributes) at the cost of considerably more verbose files.
A null value is written as an explicit <null/> or <none/> element in the
row. For how field text becomes a typed value once parsed — empty strings,
binary/BLOB syntax, literal and relative dates, UUID literals, and
booleans/numbers from strings — see Dataset Values.


