I want to write a saxon8 extension function that returns modified nodes.

The method must look something like:

public static NodeInfo setText(NodeInfo node) {

        //make copy of node and all its children, but set text value to something else

        return copy;


A NodeInfo node has not got any setters, so it's not possible to change a node.

I unsuccessfully tried finding a way to convert a converting the NodeInfo node to a DOM node, then modifying using DOM, then trying to convert to DOM node back again. Any help would be really appreciated!

For information: I successfully can return a text node using the following class:

public class MyTextNode extends net.sf.saxon.tree.NodeImpl


                private String txt;


                public MyTextNode(String txt)


                        this.txt =3D txt;=20



                public void copy(Receiver arg0, int arg1, boolean arg2, int arg3) throws XPathException {

                        throw new RuntimeException("unsupported operation!");



                public int getNodeKind() {

                        return Node.TEXT_NODE;



                public String getStringValue() {

                        return txt;



returning from the above function new MyTextNode("blabla") return a text node, but I want to return a copy of the modified node returned so this code can not help me in achieving my current goal.

With friendly greetings,

Len Feremans