The s9api method DocumentBuilder.wrap(object) does not work (throws an exception) if the object is a JDOM node or a DOM4J node.
Also, there is no convenient way to obtain an external node form the XdmNode returns by an XPathSelector or XQueryEvaluator.
A patch is being placed in Subversion (9.1 branch) to fix the first problem. It also adds a new method to XdmNode:
public Object getExternalNode()
which returns the wrapped external node if this is an XdmNode that wraps an external node, and returns null otherwise.