[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

problems with recurssion

Subject: problems with recurssion
From: "rafael vazquez" <rc_vazquez@xxxxxxxxxxx>
Date: Thu, 13 Dec 2001 18:08:30 +0100
recurssion
Hi All! I want to build a HTML document from an XML document. The XML document contains information about a shopping list. I want to build a text box for each article existing in the shopping list. Because I don´t know the number of articles in the shopping list, the name of the box for each article would be nameOfTextBox-0 for the first article, nameOfTextBox-1 for the second, and so on...
To generate the corresponding indexes of the text boxes I have to use recurssion, due to the lacking of an assignment operator for the variables.
The problem is that the following code only creates the text boxes for the first element of the list. The code is the following:


...
<xsl:template match="/LISTA">
<xsl:element name="INPUT">
 <xsl:attribute name="TYPE">TEXT</xsl:attribute>
 <xsl:attribute name="NAME">nombreLista</xsl:attribute>
  <xsl:attribute name="VALUE"><xsl:value-of select="./ID/NOMBRE_LISTA"/>
 </xsl:attribute>
</xsl:element>
<xsl:element name="INPUT">
 <xsl:attribute name="TYPE">TEXT</xsl:attribute>
 <xsl:attribute name="NAME">fechaCreacion</xsl:attribute>
  <xsl:attribute name="VALUE"><xsl:value-of select="./ID/FECHA_CREACION"/>
 </xsl:attribute>
</xsl:element>
<xsl:call-template name="articulos">
 <xsl:with-param name="numArr" select="0"/>
 <xsl:with-param name="listaNodos" select="."/>
</xsl:call-template>
<INPUT TYPE="button" onClick="alert(hidArtDC0.value)"/>
</xsl:template>


<xsl:template name="articulos"> <xsl:param name="numArr"/> <xsl:param name="listaNodos"/> <xsl:variable name="nodoAct" select="$listaNodos[1]"/> <xsl:variable name="restoNodos" select="$listaNodos[position()!=1]"/> <xsl:call-template name="crearArticulos"> <xsl:with-param name="numArr" select="$numArr"/> <xsl:with-param name="nodoAct" select="$nodoAct"/> </xsl:call-template> <xsl:if test="listaNodos"> <xsl:call-template name="articulos"> <xsl:with-param name="numArr" select="number($numArr)+1"/> <xsl:with-param name="restoNodos" select="$restoNodos"/> </xsl:call-template> </xsl:if> </xsl:template>

<xsl:template name="crearArticulos">
<xsl:param name="numArr"/>
<xsl:param name="nodoAct"/>
<xsl:element name="INPUT">
<xsl:attribute name="TYPE">HIDDEN</xsl:attribute>
<xsl:attribute name="NAME">hidArtDC<xsl:value-of select="$numArr"/></xsl:attribute>
</xsl:template>
...



My XML is...


<?xml version = '1.0' encoding='iso-8859-1'?>
<?xml-stylesheet href='../XSLT/FormatoListas.xsl' type='text/xsl'?>
<LISTA>
<ID>
<NOMBRE_LISTA>sabado</NOMBRE_LISTA>
<FECHA_CREACION>8/11/2001 10:17:16</FECHA_CREACION>
</ID>
<ARTICULO>
<DESCRIPCION_CORTA>desco_corta</DESCRIPCION_CORTA>
</ARTICULO>
<ARTICULO>
<DESCRIPCION_CORTA>desc2_corta</DESCRIPCION_CORTA>
</ARTICULO>
</LISTA>

Thanks in advance, friends!

_________________________________________________________________
MSN Photos es la manera más sencilla de compartir e imprimir sus fotos: http://photos.latam.msn.com/Support/WorldWide.aspx



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.