I'm sorry, I have no idea. I would have to do a lot of work
to find out.
The change log for Saxon 6.3 states:
still a restriction that extension functions cannot construct a new DOM tree and
return nodes from this tree by using DOM methods. They can only return existing
nodes that were constructed by Saxon itself.
It's still best to exercise caution if you go beyond that,
because if repeated calls to an extension function return the same DOM node, or
different DOM nodes in the same document, you will end up with multiple distinct
documents at the Saxon level, which can cause confiusion when doing operations
such as "union" which eliminate duplicates by identity.
When was the support for returning DOM nodes
from Java extension functions added to Saxon-B? I was trying to go through the
change logs but failed to find that entry.