The Document Table Model (DTM) is an interface to a Document Model designed specifically for
the needs of our XPath and XSLT implementations. The motivation behind this model is to optimize
performance and minimize storage.
Specifically, DTM avoids the overhead of instantiating the objects the standard DOM requires to
represent a tree of nodes. DTM uses unique integer "handles" to identify nodes, integer ID values
to represent URLs, local names, and expanded names, and integer index and length references to a
string buffer to represent the text value of each node.
In general, the "read" APIs to DTM resemble those of the W3C Document Object Model
(DOM) interface. However, in place of the DOM object tree of nodes, DTM
uses integer arrays and string pools to represent the structure and content of the XML document to
be transformed. DTM also structures the document's contents slightly differently, to better match
the XPath data model; some details and constraints present in a standard DOM are suppressed, and a
few XPath-specific features are added.
DTM is intended to be a read-only model, and so does not attempt to replicate the DOM's write or
create-node operations.
The details of constructing a DTM vary depending on which implementation of this API you are
using. Two reference implementations are currently available:
- SAX2DTM (built via a SAX stream)
- DOM2DTM (which provides DTM access to an existing DOM)
Both DTMs can be built incrementally (see incremental transforms).
When operating incrementally, the DTM allows the Xalan-Java processor to begin reading the DTM and
performing the transformation while the DTM is still being assembled (for example, while the parser
is still parsing the XML source), and attempts to do only as much work as is needed to support the
read requests actually made by the XPath or XSLT processor.
For the convenience of user-written extensions, a proxy mechanism presents the contents of the
DTM as a read-only subset of the DOM.