logolineright
bottomhttp://xml.apache.org/http://www.apache.org/http://www.w3.org/
join
Home
separator
Xalan-J 2.7.1
Charter
separator
What's New
Release Notes
separator
Overview
Download/Build
Getting Started
Using XSLTC
separator
FAQs
separator
Sample Apps
Command Line
separator
Features
Transform API
XPath API
Usage Patterns
separator
Xalan-J API
Public APIs
DTM
separator
Extensions
Extensions Library
XSLTC Exts
separator
Xalan 2 Design
XSLTC Design
separator
Building a release
Testing
Bug Reporting
separator
Contact us
close
Introduction
 

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.


DTM performance settings
 

Xalan-Java implements two DTM performance features that you can control with the TransformerFactory setAttribute(String name, Object value) method.

Attribute name (URL)  Default setting  Description 
"http://xml.apache.org/xalan/features/incremental"  false  incremental transforms 
"http://xml.apache.org/xalan/features/optimize"  true  optimized transforms 

Both of these DTM settings are described below.

'http://xml.apache.org/xalan/features/incremental'
 

Set this feature to true to enable incremental transformations. If set to false (the default), the transform and the parse are performed on the same thread.

Note When set to true: If the parser is Xerces, we perform an incremental transform on a single thread using the Xerces "parse on demand" feature. If the parser is not Xerces, we run the transform in one thread and the parse in another. Exception: if the parser is not Xerces and the XML source is a DOMSource, setting this feature to true has no effect.
Note The incremental feature is not currently supported by the XSLT Compiling processor, XSLTC.

Example: setting incremental transforms to true (for the XSLT Interpretive processor):

javax.xml.transform.TransformerFactory tFactory =
            javax.xml.transform.TransformerFactory.newInstance();
 // setAttribute() takes a String and an Object.            
  tFactory.setAttribute
            ("http://xml.apache.org/xalan/features/incremental", 
             java.lang.Boolean.TRUE);
  ...

'http://xml.apache.org/xalan/features/optimize'
 

When set to true (the default), this feature enables optimizations that may involve structural rewrites of the stylesheet. Any tool that requires direct access to the stylesheet structure should set this feature to false.



DTM node location tracking setting
 

The DTM also provides a setting that you can use to track location information for each node in the source document. See "http://apache.org/xalan/features/source_location"



dot
Copyright © 2006 The Apache Software Foundation. All Rights Reserved.