Handling of source documents
Whitespace stripping: If you supply any kind of pre-built tree as input to the transformation (that is, if the Source object is a DOMSource or a NodeInfo), then Saxon no longer strips down the tree and rebuilds it to implement whitespace stripping. Instead, if whitespace stripping has been requested, it wraps the supplied tree in a whitespace-stripping envelope, which hides whitespace text nodes that the stylesheet has asked to be stripped, on the fly. Because this is done in a separate layer above the data model, it works for all data model implementations (JDOM, DOM, and native Saxon), and it imposes no overhead when it is not needed - that is, when the stylesheet doesn't request whitespace stripping, and when nodes are stripped during tree construction, which is still done if you supply a SAXSource or StreamSource as the input). {axes-dom154, 155}
Note that this whitespace stripping layer strips whitespace as requested by the stylesheet,
regardless of whether any xml:space
attribute is present in the tree to override this.
In the XQuery interface, whitespace stripping can be requested from the command line or from the API, but not from the query itself.
Whitespace stripping applies equally to documents loaded using the document()
or doc()
function as to
the initial source document; but it is not applied to documents supplied as stylesheet (or query)
parameters.
This model now allows the XQuery and XPath APIs to operate directly on a DOM or JDOM structure, with the results of the expression being references to the actual DOM or JDOM nodes, not to copies.