If the expected type is a generic collection type, or an array of the Saxon class
NodeInfo, or a
SequenceIterator, Saxon will pass the nodes supplied in the call in their native
Saxon representation, that is, as instances of
Saxon recognizes methods that expect nodes in an external object model (DOM, DOM4J, JDOM, or XOM) only if the supporting JAR file is on the classpath (that is, saxon9-dom.jar, saxon9-dom4j.jar, saxon9-jdom.jar, or saxon9-xom.jar). In all four cases, if the XPath node is actually a view of a DOM, DOM4J, JDOM, or XOM node, then the underlying node will be passed to the method. If the XPath node is a text node that maps to a sequence of adjacent text and/or CDATA nodes in the underlying model, the first node in this sequence will be passed to the extension function.
In addition, in the case of DOM only (but only if saxon9-dom.jar is on the classpath), if the XPath node
is not a view of a DOM node, Saxon will create a DOM wrapper for the native Saxon node, and pass this wrapper.
This is also done if the required type is a DOM NodeList. Note that the wrapper is a read-only
DOM implementation: any attempt to update nodes through the wrapper interface will throw an exception.
A consequence of the way the
wrapping works is that it's not safe to rely on object identity when testing node identity - the same node can be represented by
more than one Java object. Use the DOM method