Is there a simple way to have an extension function in XSLT 1.0 written in javascript return a node-set?
I could create a new java class for this, but I would rather just put some code in the script itself.
When this can be done in another scripting language supported by all or most XSLT processors (VB script? Groovy? C#?), then that s OK too of course.
我有以下简单的文字:
<msxsl:script language="JScript" implements-prefix="custom">
function xml (input) {
var x = input.split(";");
return x.toString();
}
</msxsl:script>
which returns a string, and hence no problem calling the function in Xpath expressions.
What I would like to have, is a node-set result. But when I change my script to
<msxsl:script language="JScript" implements-prefix="custom">
function xml (input) {
var x = input.split(";");
return x;
}
</msxsl:script>
然后,称职造成错误,因为阵列不会自动转换为 no。
见arrays-with-java-xslt-extensions。 但是,这更符合为此设立一个新类别的规定,我现在要避免。
因此,在文字中应加上哪些声明,以便把阵列变成一个节点,使功能在Xpath表述中使用?