使用 XSLT1 如何简单地分配一个从 1 开始的递增值?

Using XSLT1 how can I simply assign an incrementing value beginning with 1?

在我的 XSL 脚本中有以下内容:

<body>
    <xsl:for-each select="MeetingWorkBook/Meeting">
        <xsl:apply-templates select="TFGW/BibleReadingItem/Readers/Reader"/>
        <xsl:apply-templates select="AYFM/StudentItem/Students/Student"/>
    </xsl:for-each>
</body>

模板的开头是:

<xsl:template match="Student | Reader">
    <xsl:if test="self::Student">
         <hr/>
    </xsl:if>
    <div>
        <xsl:attribute name="id">
            <xsl:text>containter-student-slip</xsl:text>
            <xsl:variable name="pos" select="position()"/>
            <xsl:value-of select="$pos"/>
        </xsl:attribute>

我希望 id 只是一个数值,从 1 开始并向上。

我意识到使用 position() 不好,因为它与两种匹配元素类型相关。

如何使用 XSLT1 简单地分配一个从 1 开始的递增值?

如果您想使用 position(),您可能*只需更改:

<xsl:for-each select="MeetingWorkBook/Meeting">
    <xsl:apply-templates select="TFGW/BibleReadingItem/Readers/Reader"/>
    <xsl:apply-templates select="AYFM/StudentItem/Students/Student"/>
</xsl:for-each>

至:

<xsl:for-each select="MeetingWorkBook/Meeting">
    <xsl:apply-templates select="TFGW/BibleReadingItem/Readers/Reader | AYFM/StudentItem/Students/Student"/>
</xsl:for-each>

或者*,可以使用 xsl:number


(*) 当然,如果没有可重现的例子,这些只是猜测。