XSL only shows 10 cycles in each

My XML has 100 AgentSales nodes. I want to show only the first 10, while I have

<xsl:for-each select="NewDataSet/AgentSales">
    <tr>
        <xsl:if test="(position() mod 2 = 1)">
            <xsl:attribute name="bgcolor">#cccccc</xsl:attribute>
        </xsl:if>
        <td>
            <span style="font:20px arial; font-weight:bold;">
                <xsl:value-of select="AgentName"/>
            </span>
        </td>
        <td>
            <span style="font:20px arial; font-weight:bold;">
                <xsl:value-of select="State"/>
            </span>
        </td>
        <td>
            <span style="font:20px arial; font-weight:bold;">
                <xsl:value-of select="time"/>
            </span>
        </td>
    </tr>
</xsl:for-each>

New on the site, but when I use code brackets, do not all of my codes show? at least not in the preview below.

+5
source share
2 answers

Using

<xsl:for-each select="NewDataSet/AgentSales[not(position() >10)]">
  <!-- Process each node from the node-list -->
</xsl:for-each>

Even better :

<xsl:apply-templates select="NewDataSet/AgentSales[not(position() >10)]"/>
+6
source

Try something like:

<xsl:for-each select="NewDataSet/AgentSales">
    <xsl:if test="position() &lt;= 10">
        ...
    </xsl:if>
</xsl:for-each>
+2
source

All Articles