Friday, January 13, 2006

Xsl Recursion

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/listado">
<xsl:call-template name="habitante">
<xsl:with-param name="municipio" select="/listado/datos_ayto/nombre"/>
<xsl:with-param name="habitante" select="/listado/habitantes/habitante"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="habitante">
<xsl:param name="i" select="1" />
<xsl:param name="habitante" />
<xsl:value-of select="$i"/>
<xsl:value-of select="$habitante"/>
<xsl:variable name="sgte" select="$habitante/following-sibling::*" />
<xsl:if test="$sgte">
<xsl:call-template name="habitante">
<xsl:with-param name="habitante" select="$sgte"/>
<xsl:with-param name="i" select="$i + 1 "/>
</xsl:call-template>
</xsl:if>

</xsl:template>
</xsl:stylesheet>

0 Comments:

Post a Comment

<< Home