Firstly, I would say that transforming XML nodes into other
XML nodes is easier to do in XSLT than in Java (which you would expect, really,
because XSLT is designed explicitly for that job).
Secondly, Saxon's XML nodes are in general immutable. By
default the tree for your xsl:variable will use the TinyTree model, which you
can't modify in-situ. Some tree models can be modified, but it probably isn't a
good idea to do this because extension functions with side effects can behave
Using document() is appropriate where the input to your
extension is a string or URI, but not where it is a node.
You don't actually say what you want your extension function
to do, which makes it difficult to give you design advice.
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">
=== 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,