【发布时间】:2022-01-15 23:49:23
【问题描述】:
对于每个组,我必须按具有相同编号的艺术家进行分组。在输出中,我必须显示每个组的位置(输出:1、2、3),但是在进入组的第二个循环时位置会重置,并且当前的输出是(错误输出:1,2 ,1)。
<xsl:for-each select="group"> <xsl:for-each-group select="artist" group-by="number"> <position> <xsl:value of select="position()"/> </position> <counter> <xsl:value of select="count(number)"/></counter> </xsl:for-each-group> </xsl:for-each>
or
<xsl:for-each select="group"> <xsl:for-each-group select="artist" group-by="number"> <position> <xsl:value of select="position()"/> </position> <counter> <xsl:value of select="count(number)"/></counter> </xsl:for-each-group> </xsl:for-each>
<?xml version="1.0" encoding="UTF-8"?>
<group>
<artist>
<number>1</number>
</artist>
<artist>
<number>1</number>
</artist>
<artist>
<number>2</number>
</artist>
<artist>
<number>2</number>
</artist>
</group>
<group>
<artist>
<number>5</number>
</artist>
<artist>
<number>5</number>
</artist>
</group>
【问题讨论】:
-
请编辑您的问题并显示 (1) 格式正确的输入和 (2) 预期输出。