xsl-list
[Top] [All Lists]

Re: Counting using variable inside the loop

2004-03-11 02:29:05
If you litrally want to count the number of row elements in xsl do
<xsl:variable name="count" select="count(//row)"/>

----- Original Message ----- 
From: "Arulraj" <p_arulraj(_at_)yahoo(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, March 11, 2004 9:12 AM
Subject: [xsl] Counting using variable inside the loop


Hello,
  I want to count number of row element in XML. 

My XML content look like this

<layout>
  <table>
      <rowseparator/>
      <row>
        <cell>
      </row>
      <rowseparator/>
      <rowseparator/>
      <row>
<cell>
      </row>
  </table>
</layout>

In my XSL file I am traversing this XSL file using
for-each select="child::*"
I want to find the row position. If I use 
<xsl:value-of select="position()"/>
it returns 2 and 5

But I want to make a count row, when I reach first row
I should this is first row. when next row encounter I
should say this is second row.

I tried with <xsl:variable>


<xsl:template name="table_element_traversal">
<xsl:variable name="rowcount">0</xsl:variable>

<xsl:if test="row">
    <xsl:variable name="rowcount
select="$rowcount+1"/>
    <xsl:value-of select="$rowcount"/>
</xsl:if>
</xsl:template>

I am getting parser error conflicting variable
bindings 'rowcount' 
How to solve this in XSL?
Any idea,
Thank you
Regards,
Arul


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you're looking for faster
http://search.yahoo.com

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


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