[xsl] Use of XSLT 3 current-merge-group() as argument to user-defined function

Subject: [xsl] Use of XSLT 3 current-merge-group() as argument to user-defined function
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Aug 2018 18:20:57 -0000
I am trying to use the function current-merge-group inside of an xsl:merge-action in a call to a user-defined function

<xsl:merge-action>
<xsl:sequence select="mf:my-fun(current-merge-group(), $levels-to-reconstruct - 1)"/>
</xsl:merge-action>


While that works fine with Altova I don't get it to work with Saxon 9.8, even with HE or with a stylesheet not using streamable merge sources, Saxon indicates "XTDE3480: There is no current merge group".

Looking at the spec https://www.w3.org/TR/xslt-30/#dt-current-merge-group it says "The current merge group and current merge key are available within the sequence constructor contained by an xsl:merge-action element." and "All invocation constructs set the current merge group and current merge key to absent" where the section https://www.w3.org/TR/xslt-30/#dt-invocation-construct then details "XPath function calls that bind to stylesheet functions" as one of the invocation constructs so Saxon seems to be following the spec to reject the use of current-merge-group() as the argument to my function.

I wonder why there is that restriction, at least when no streaming is used I can't directly see a reason why a merge group can't be passed on to a function.

I can rewrite the code to

<xsl:merge-action>
<xsl:sequence select="let $group := current-merge-group() return mf:my-fun($group, $levels-to-reconstruct - 1)"/>
</xsl:merge-action>


to have it executed in Saxon as well.

Why does the spec not allow passing current-merge-group() directly to a user defined function?

Current Thread