Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Sort and count all elements [Thread Next] Re: Sort and count all elementsTo: NULL Date: 7/13/2009 2:06:00 PM Shilpa Mahajan wrote: > I want to print the "book genre and total no of books with that > genre". For e.g Computer - 4 , Fantancy - 4 , Romance - 1. Here is an XSLT 2.0 stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each-group select="catalog/book" group-by="genre"> <xsl:sort select="count(current-group())" order="descending"/> <xsl:value-of select="concat(genre, ' - ', count(current-group()), ' ')"/> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> You can use XSLT 2.0 with Saxon 9 (http://saxon.sourceforge.net/), AltovaXML tools (http://www.altova.com/), or Gestalt (http://gestalt.sourceforge.net/). -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
