Nested for-each-group with current-group() referenced in for-each-group/@select
--- a/tests/insn/for-each-group/_for-each-group-test-set.xml Wed Jun 13 12:33:36 2018 +0100
+++ b/tests/insn/for-each-group/_for-each-group-test-set.xml Wed Jun 13 12:34:38 2018 +0100
@@ -1497,4 +1497,21 @@
<assert-xml file="for-each-group-043.out"/>
</result>
</test-case>
+
+ <test-case name="for-each-group-088">
+ <description>Reference current-group() in for-each-group/@select</description>
+ <created by="Michael Kay" on="2018-07-07"/>
+ <environment ref="group029"/>
+ <dependencies>
+ <spec value="XSLT20+"/>
+ </dependencies>
+ <test>
+ <stylesheet file="for-each-group-088.xsl"/>
+ </test>
+ <result>
+ <all-of>
+ <assert>/table/pop[@value='5']/deep-equal(data(city/@name), ('milan', 'bristol', 'sheffield'))</assert>
+ </all-of>
+ </result>
+ </test-case>
</test-set>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/for-each-group/for-each-group-088.xsl Wed Jun 13 12:34:38 2018 +0100
@@ -0,0 +1,16 @@
+<?spec xslt#grouping?>
+<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xsl:template match="/">
+ <table>
+ <!-- Reference current-group() within group-by expression -->
+ <xsl:for-each-group select="cities/city" group-by="xs:decimal(@pop)">
+ <pop value="{current-grouping-key()}">
+ <xsl:for-each-group select="current-group()" group-by="@name[../@pop = current-group()/@pop]">
+ <city name="{@name}"/>
+ </xsl:for-each-group>
+ </pop>
+ </xsl:for-each-group>
+ </table>
+ </xsl:template>
+</xsl:transform>