Tengo pocas dificultades para asignar una variable de contador y aumentarla y luego verificar un cierto valor en XSLT. Aquí está mi código:Incrementando y comprobando la variable de contador en XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:variable name="empty_string"/>
<xsl:variable name="counter" select="0"/>
<xsl:template match="/Collection">
<xsl:for-each select="Content">
<xsl:sort select="Html/root/Event/start_date" order="ascending"/>
<xsl:variable name="isFutureEvent">
<xsl:value-of select="syscom:isFutureDate(Html/root/Event/start_date)" />
</xsl:variable>
<xsl:if test="Html/root/Event != $empty_string">
<xsl:if test="$isFutureEvent='true'">
<!-- Increment Counter -->
<xsl:value-of select="$counter + 1"/>
<!-- Test if Counter < 4 -->
<xsl:if test="$counter < 3">
<div class="media">
<!-- Do stuff here -->
</div>
</xsl:if> <!-- End if for counter -->
</xsl:if>
</xsl:if>
<!--</xsl:when>-->
<!--</xsl:choose>-->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
pero, duerma parecen incrementar mi contador y no salir cuando el contador golpea 3. Cualquier ayuda en esto?
Desafortunadamente, Saxon está limitado a XSLT versión 2.0, por lo que no puede utilizar esta solución con la edición gratuita . – Hraban