I have define a function that returns a the first node for a passed in node set.  For example:

 

            <func:function name="my:getSomeElementOfANodeSet">

                        <xsl:param name="nodes"/>

 

                        <xsl:for-each select="$nodes">

                                    <xsl:sort select="some sort criteria based on children nodes" order="descending"/>

                                    <xsl:if test="position() = 1">

                                                <func:result select="."/>

                                    </xsl:if>

                        </xsl:for-each>

            </func:function>

 

 

This function works fine.

 

However, if I assign the results to a variable, a strange things happens (or maybe it is intended behavior).

 

<xsl:variable name=”try1” select=”my:getSomeElementOfANodeSet(theNodeSet)”/>

 

……blah blah blah…….

 

<xsl:copy-of select=”$try1”/>   <!—everything is great, I output the node à

 

<SomeNode attrib1=”{local-name(my:getSomeElementOfANodeSet(someOtherNodeSet))}”/>  

 

            <xsl:copy-of select=”$try1”/>  <!—Yikes, $try1 is now different.  It is the node from the last call made, not the original call à

 

The point that I’m trying to illustrate is that for some reason, when I call the function again with a different node set

the value of the variable, $try1 is equal to the result of the last function call.

 

Is this intended behavior?

 

Reply via email to