Skip to content

dataset.dtd does not declare the <none/> element used by XmlProducer/XmlDataSetWriter #925

Description

@jeffjensen

Description

src/main/resources/org/dbunit/dataset/xml/dataset.dtd — the DTD XmlProducer validates incoming documents against when setValidating(true) is enabled — does not declare the <none/> element, even though XmlProducer and XmlDataSetWriter both read and write it to represent ITable.NO_VALUE (a column with no value provided, distinct from an explicit <null/>).

Any XML dataset document containing <none/>, parsed with validation enabled, fails with:

org.dbunit.dataset.DataSetException: Line 1: Element type "none" must be declared.

Root cause

<none/> was intentionally removed from dataset.dtd in 2002 (commit 56c8cb5, "<none/> is not supported anymore") ahead of adding binary data type support. Support was reintroduced into the XML producer during the 2003–2004 Electric XML → SAX2 rewrite (commit 4551af2; see also the 2.0 and 2.1 changes.xml entries, the latter explicitly documenting <none/> as the mechanism for omitting values from generated INSERT statements), but the shipped dataset.dtd resource was never updated to match. XmlDataSet's own class-level Javadoc already documents the correct, complete DTD (including <!ELEMENT none EMPTY>), so the code and its own documentation have been ahead of the packaged validation DTD for roughly two decades.

Impact

Only affects callers that explicitly enable DTD validation (XmlProducer.setValidating(true)); non-validating use (the default) is unaffected. No existing test exercised this combination, which is how it went unnoticed for so long.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: datasetIDataSet, ITable, Column, dataset implementationsformat: xmlFlatXmlDataSet, XmlDataSet

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions