I am currently working on pure XSL conversion with a Saxon processor in different versions. Below is my small stylesheet simplified for the needs of my question:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:foo="bar"> <xsl:output encoding="UTF-8" method="text"/> <xsl:template match="/"> <xsl:text>Call of func_1: </xsl:text> <xsl:value-of select="foo:func_1()"/> <xsl:text>
Call of func_1: </xsl:text> <xsl:value-of select="foo:func_1()"/> <xsl:text>
Call of func_1: </xsl:text> <xsl:value-of select="foo:func_1()"/> <xsl:text>
Call of func_2: </xsl:text> <xsl:value-of select="foo:func_2()"/> </xsl:template> <xsl:function name="foo:func_1" as="xs:string"> <xsl:value-of select="foo:func_2()"/> </xsl:function> <xsl:function name="foo:func_2" as="xs:string"> <xsl:variable name="node"> <xsl:comment/> </xsl:variable> <xsl:sequence select="generate-id($node)"/> </xsl:function> </xsl:stylesheet>
Description
foo:func_1 is a wrapper function that returns the value of the second function + doing other things that can be ignored. This function concept calls another function required!
foo:func_2 generates a unique identifier for an element. This item is created in a local cloud variable named "node".
Various results based on Saxon versions
Expected Result:
Call of func_1: d2 Call of func_1: d3 Call of func_1: d4 Call of func_2: d5
Saxon-EE 9.6.0.7/Saxon-EE 9.6.0.5 result
Call of func_1: d2 Call of func_1: d2 Call of func_1: d2 Call of func_2: d3
Saxon-HE 9.6.0.5/Saxon-PE 9.6.0.5/Saxon-EE 9.5.1.6/Saxon-HE 9.5.1.6 result
like expected
Question / in more detail
I debugged the problem myself as much as I could. IF I change the xsl:value-of function in the "func_1" function to xsl:sequence , the results will be the same for all versions [as expected]. But this is not my intention!
I want to understand what is the difference between xsl:value-of and xsl:sequence in Saxon versions. Is there hidden caching? What is the correct way to work with xsl:sequence and xsl:value-of in my case. [btw: I already know, value-of creates node text with the result of select-statement. the sequence can be a reference to a node or an atomic value. don't solve my afaik problem]
uL1
source share