If you're using Xalan-J, the easiest solution is for your extension to just return the Node. Our extension code checks the type of the returned object and does Something Appropriate with it, as described in http://xml.apache.org/xalan-j/extensions.html#ext-functions under "return values". If you return a DOM Node from your extension, Xalan-J will treat it as a Node Set automagically.
I'm not sure what the corresponding answer would be for Xalan-C.
