In this paper, we demonstrate a natural mapping from element types
of XML to module expressions of ML-like programming languages.
The mapping is inductive, and the definitions of common XML
operations can be derived as the module expressions are constructed.
We show how to derive, in a generic way, the validation function,
which checks an XML document for conformance to the content model
specified by its DTD (Document type definition).
One can view the validation function as giving types to
XML elements, and the validation procedure a pre-requirement
for typeful XML programming in ML.
Our mapping of XML element types to ML module expressions
uses the parametric module facility of ML in some contrived way.
For example, in validating WML (WAP markup language) documents,
we need to use 36-ary type constructors, as well as higher-order
modules that take in as many as 17 modules as input.
That one can systematically model XML DTD at the module level
suggests ML-like languages are suitable for
type-safe prototyping of DTD-aware XML applications.