Bug #4314
closedProblem using current-merge-group() as argument to function call on the right hand side of simple map expression
0%
Description
Using Saxon-HE 9.9.1.5J, I have run into a problem when I try to use use current-merge-group()
inside of xsl:merge-action
but in an XPath expression that uses the simple map operator !
; Saxon the refuses to run the code claiming there is no current merge group: "XTDE3480: There is no current merge group".
A much reduced and not very meaningful test case that demonstrates the problem is:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mf="http://example.com/mf"
expand-text="yes"
exclude-result-prefixes="#all">
<xsl:output indent="yes"/>
<xsl:function name="mf:test" as="item()*">
<xsl:param name="i1" as="xs:integer*"/>
<result>{sum($i1)}</result>
</xsl:function>
<xsl:template match="/" name="xsl:initial-template">
<root>
<xsl:merge>
<xsl:merge-source select="1 to 10">
<xsl:merge-key select=". idiv 5"></xsl:merge-key>
</xsl:merge-source>
<xsl:merge-action>
<xsl:message select="position(), ': ', current-merge-group()"/>
<xsl:sequence select="(1 to 3) ! mf:test(current-merge-group())"/>
</xsl:merge-action>
</xsl:merge>
</root>
</xsl:template>
</xsl:stylesheet>
Output when run from the command line with -it -xsl:map-expression-problem1.xsl
:
Processing (no source document) initial template = xsl:initial-template
1 : 1 2 3 4
Error evaluating (fn:sum(...)) in xsl:sequence/@select on line 23 column 87 of map-expression-problem1.xsl:
XTDE3480: There is no current merge group. Found while atomizing the first argument of mf:test()
at template xsl:initial-template on line 15 of map-expression-problem1.xsl:
invoked by unknown caller (null)
at template xsl:initial-template on line 15 of map-expression-problem1.xsl:
invoked by unknown caller (null)
at template xsl:initial-template on line 15 of map-expression-problem1.xsl:
invoked by unknown caller (null)
There is no current merge group. Found while atomizing the first argument of mf:test()
As the call to the mf:test
is inside of an xsl:merge-action
I think the current-merge-group()
should be present. Somehow the use of the map operator !
seems to trigger this so I suppose that Saxon rewrites the code and doing it in a way that makes it claim that the merge group is absent.
Please register to edit this issue