Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Counting total of groups

From: Francisco <francisco@-------------->
To:
Date: 6/1/2006 9:56:00 AM
Hi,

I have read the documentation regarding the grouping and the different 
examples to count the different groups and now my xslt file is doing 
this but I need as well to sum the different groups to have a total of 
groups but I can't get working.

How I can get this result before enter the for-each loop? I need this 
before to make a paginate page.



So If I have:
Group1
 2 elements
Group2
1 element
Group3
3 elements
I need to have that the number of groups is 3.

<?xml version="1.0" encoding="ISO-8859-1"?>

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

<xsl:output method="html" omit-xml-declaration="yes" 
encoding="ISO-8859-1"/>    
<xsl:key name="hotelname" match="product" use="name" />

<xsl:template match="body">

<xsl:param name="counter" select="0"/>

   <xsl:for-each select="product[count(. | key('hotelname', name)[1]) = 
1]">  
       Number of elements for this group : <xsl:value-of 
select="$counter + count(key('hotelname', name))" /><br></br>

       <xsl:sort select="name" />

       <xsl:value-of select="name" />,<br />

       <xsl:for-each select="key('hotelname', name)">

           <xsl:value-of select="productID" /> <br />

                      <xsl:with-param name="counter" select="$counter + 
1"/>

       </xsl:for-each>

   </xsl:for-each>

</xsl:template>



</xsl:stylesheet>




I would appreciate your help
Regards
Frank


Chasetravel.ie, Winner ITTN Awards 2005.
       "Best Hotel Booking Engine"


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent