特定の名前のノードの出現をカウントする方法がわかりません。
これは私の構造です:
<xsl:variable name="pageType" select="/verticaldata/context/querystring/parameter[@name = 'type']"/>
<xsl:template match="/">
<xsl:if test="number(/verticaldata/contents/@totalcount) > 0">
<xsl:apply-templates select="verticaldata/contents/content"/>
</xsl:if>
</xsl:template>
<xsl:template match="content">
<xsl:variable name="itemType" select="contentdata/type">
<xsl:if test="$pageType = $itemType">
<xsl:call-template name="displayItem"/>
</xsl:if>
</xsl:template>
<xsl:template name="displayItem">
<!-- Here I want to show the item number in the id -->
<div class="item">
<xsl:attribute name="id">
<xsl:value-of select="count(preceding-sibling::content)"/>
</xsl:attribute>
<!-- Item renders here -->
</div>
</xsl:template>
私は position() と count(preceding-sibling::content) を試しましたが、それらはすべて「タイプ」チェックを通過したアイテムの数ではなく、合計数を示しています。以前に作成された「displayItem」ノードの数を取得するにはどうすればよいですか?
これは可能ですか?
// ダニエル