Hi,

I'm dealing with a dilemma ..about how to implement an XSLT integrated extension function which takes as input an XML node and returns a (different) XML node for further processing.
I am not an expert in XSLT / Saxon processing, so please correct me if I'm wrong in any way..

Reading in Dr. Kay's book "XSLT 2.0 and XPath 2.0" (in the section regarding Extension functions), it seems that doing such a thing "might be easier using the document() approach". 
I am not familiar with this approach, so as a "side question" I would like to ask if using that approach I have both possibilities (i.e. passing an XML node to the "extension" and, after some processing of the input, returning another XML node for further processing).

Basically the input XML file which is going to be processed by the transformer will look like this:

=== input XML
<variable name="myvar" type="xml">
   <data>
      ....
   </data>
</variable>
...
<eval expr="prefix:function($myvar)"/>
=== input XML

.. when the prefix:function($myvar) will be called, I would like to have the entire XML node  visible above named "variable" (and in the exact format as in the input XML) available for further processing in the $myvar. After processing this input XML node provided as an argument to the extension function (processing which cannot be done anywhere but inside a java component), the extension function will return an output XML node which will be then used in the transformation ( by the way.. does the transformer knows how to handle this "dynamic" scenario when additional nodes are inserted in the input XML?).

Can you please tell me how one achieves such a thing using extension functions? If there is any other way for achieving this with Saxon 9.2, I would be glad to know about it..
If there are any places where such an implementation is done, please name it and I will look into it for further details.

Thank you in advance for your help,
M.