¿Cómo guardo las iteraciones que se han producido en un xsl: for-each? (las variables en XSL son inmutables)xsl: para cada contador de bucle
Mi objetivo es encontrar el número MAX de hijos para cualquier nodo en un nivel particular.
Por ejemplo, puede ser que quiera imprimir que no hay más de 2 nodos de respuesta para cualquier pregunta de esta encuesta:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="testing.xsl"?>
<Survey>
<Question>
<Response text="Website" />
<Response text="Print Ad" />
</Question>
<Question>
<Response text="Yes" />
</Question>
</Survey>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:for-each select="Survey">
The survey has <xsl:value-of select="count(child::Question)"/> questions.
<br />
<xsl:variable name="counter">0</xsl:variable>
<xsl:for-each select="Question">
<!-- TODO: increment the counter ??????? -->
</xsl:for-each>
No more than <xsl:value-of select="$counter"/> responses were returned for any question.
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>