Subject: Re: [xsl] Use of XSLT 3 current-merge-group() as argument to user-defined function|
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Aug 2018 22:11:10 -0000
This looks like a bug. It shouldn't be possible to call current-merge-group() within the called function, but it should be possible to call it while evaluating an argument of the function call. The reason for the restriction is to reduce the amount of context that has to be passed to functions/templates just in case it is needed, and to increase the potential for static analysis. This is of course particularly important for streaming, but it's useful elsewhere as well. And there was a desire to have no needless differences between the streaming and non-streaming cases. Michael Kay Saxonica > On 23 Aug 2018, at 19:21, Martin Honnen martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > > 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?
|<- Previous||Index||Next ->|
|[xsl] Use of XSLT 3 current-merge-g, Martin Honnen martin||Thread|
|[xsl] Use of XSLT 3 current-merge-g, Martin Honnen martin||Date|