SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
| Source Documents on the Command Line
| Saxon and XML 1.1
| JAXP Source Types
» | Third-party Object Models: DOM, JDOM, and XOM
| Choosing a Tree Model
| The PTree File Format
| Validation of Source Documents
| Whitespace Stripping in Source Documents
| Serial Processing of Large Documents
XML Schema Processing
The XPath API
Standards Conformance
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
XSLT Patterns

# Third-party Object Models: DOM, JDOM, and XOM

Saxon allows various third-party object models to be used to supply the input to a transformation or query. Specifically, it supports DOM, JDOM, and XOM. For each of these models there is a support module in its own JAR file: saxon8-dom.jar, saxon8-jdom.jar, or saxon8-xom.jar. The relevant object model is not recognized unless the appropriate support module is on the classpath.

For DOM input, the source can be supplied by wrapping a `DOMSource` around the DOM Document node. For JDOM and XOM, the approach is similar, except that the wrapper classes are supplied by Saxon itself: they are `net.sf.saxon.jdom.DocumentWrapper` and `net.sf.saxon.xom.DocumentWrapper` respectively. These two wrapper classes implement the Saxon `NodeInfo` interface (which means that they also implement `Source`).

None of these models is likely to be as efficient as using Saxon's native tree model. For best performance, you should avoid using a DOM, JDOM, or XOM source. These models should only be used if your application needs to construct them for other reasons.

Saxon supports these models by wrapping each DOM, JDOM, or XOM node in a wrapper that implements the Saxon `NodeInfo` interface. When nodes are returned by the XQuery or XPath API, these wrappers are removed and the original node is returned. Similarly, the wrappers are generally removed when extension functions expecting a node are called.

In the case of DOM only, Saxon also supports a wrapping the other way around: an object implementing the DOM interface may be wrapped around a Saxon NodeInfo. This is done when Java methods expecting a DOM Node are called as extension functions, if the NodeInfo is not itself a wrapper for a DOM Node.

Next