This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problems with recurssion


Hi Rafael,

> 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.

Well, you don't *have* to. In fact, in this case I think you'd
probably be better off using xsl:for-each and the position() function
to give a counter for the nodes. You could do something like:

  <xsl:for-each select="ARTICULO">
    <xsl:variable name="numArr" select="position() - 1">
    <INPUT TYPE="HIDDEN" NAME="hidArtDC{$numArr}" />
  </xsl:for-each>

to get one INPUT element for each ARTICULO.

The reason your recursive template wasn't working, by the way, was
that when you first called the template you used:

  <xsl:with-param name="listaNodos" select="." />

which passed the LISTA element into the $listaNodes parameter. I think
you wanted to pass the ARTICULO elements in, then select the first to
work on and the rest to pass on to the next recursion. Note that for
your crearArticulos named template to work the way I think you want it
to, you should probably change the context node to the first node in
the $listaNodos list (using xsl:for-each).

But like I said, a xsl:for-each is the simple way to do it, I think.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]