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

RE: getting the counter for a for-each statement

Subject: RE: getting the counter for a for-each statement
From: "Jaime A Stuardo Bahamondes" <jstuardo@xxxxxxxxxxx>
Date: Thu, 11 Dec 2003 14:22:36 -0400
xsl for each counter
That doesn't work since the context node isn't the node for the for-each.

This is the complete for-each:

<xsl:for-each select="ROW[count(. | key('tipos', D)[1]) = 1]">
  a_valores[<xsl:value-of select="position()-1" />] = new Array(<xsl:value-of select="count(. | key('tipos', A)[1])" />);      
  a_valores[<xsl:value-of select="position()-1" />][<xsl:value-of select="count(. | key('tipos', D))-1" />] = new Array(2);
  a_valores[<xsl:value-of select="position()-1" />][<xsl:value-of select="count(. | key('tipos', D))-1" />][0] = <xsl:value-of select="D" />;
  a_valores[<xsl:value-of select="position()-1" />][<xsl:value-of select="count(. | key('tipos', D))-1" />][1] = <xsl:value-of select="D" />;  
</xsl:for-each>

This follows the muenchian grouping algorithm. In that case position() gets the parent of ROW since the template is:
<xsl:template match="ficha_tecnica/ROWSET">

The way I have now is by using count(. | key('tipos', D)) and it works, but I think that if I have more data, that process will be inefficient since it has to count the actual nodes for each iteration.

My for-each gets the following:

a_valores[0] = new Array(1);      
a_valores[0][0] = new Array(2);
a_valores[0][0][0] = .30726074;
a_valores[0][0][1] = .30726074;  
      
a_valores[1] = new Array(1);      
a_valores[1][0] = new Array(2);
a_valores[1][0][0] = .12244368;
a_valores[1][0][1] = .12244368;  
      
a_valores[2] = new Array(1);      
a_valores[2][0] = new Array(2);
a_valores[2][0][0] = .4071683;
a_valores[2][0][1] = .4071683;  


Jaime

> -----Mensaje original-----
> De: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]En nombre de David
> Carlisle
> Enviado el: Jueves, 11 de Diciembre de 2003 12:32
> Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Asunto: Re:  getting the counter for a for-each statement
> 
> 
> 
> this has already been answered today in a differentthread.
> <xsl:value-of select="position()"/>
> 
> 
> 
> -- 
> http://www.dcarlisle.demon.co.uk/matthew
> 
> ______________________________________________________________
> __________
> This e-mail has been scanned for all viruses by Star Internet. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ______________________________________________________________
> __________
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 

 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.