I have a problem passing a NodeSet into a java xslt extension. In the
extension, I want to use the string representation of the NodeSet (including
markup). I have tried several methods on different objects:
6.2.2 is a long time ago so the following might not be completely accurate, but the same principles should hold.
You need to create an Outputter (from package com.icl.saxon.output), initialized to use the XML output method and a StreamResult using a StringWriter to capture the output. Then use the copy() method on each node in the node-set to serialize the node to this output destination.
The usual way of creating an Outputter is through a method such as changeOutputDestination() in the Controller. You may be able to do it more direcly (because you don't need to change the current output destination for XSLT instructions) but the logic there may be a helpful guide. Remember to initialize the NamePool used by the Outputter - that's the only way it knows how to translate element and attribute numbers into serialized names.
Mike Kay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have a problem passing a NodeSet into a java xslt extension. In the
extension, I want to use the string representation of the NodeSet (including
markup). I have tried several methods on different objects:
NodeSetValue.evaluateAsString()
NodeInfo.copyStringValue()
NodeInfo.getValue()
Some return the string contents of the first node (like <xsl:value-of>), but none the string representation of the complete node.
Has anybody any idea how to do this in Saxon 6.2.2?
regards,
eric
6.2.2 is a long time ago so the following might not be completely accurate, but the same principles should hold.
You need to create an Outputter (from package com.icl.saxon.output), initialized to use the XML output method and a StreamResult using a StringWriter to capture the output. Then use the copy() method on each node in the node-set to serialize the node to this output destination.
The usual way of creating an Outputter is through a method such as changeOutputDestination() in the Controller. You may be able to do it more direcly (because you don't need to change the current output destination for XSLT instructions) but the logic there may be a helpful guide. Remember to initialize the NamePool used by the Outputter - that's the only way it knows how to translate element and attribute numbers into serialized names.
Mike Kay