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:24: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. If you need an XSLT 1.0 solution then here is one using Muenchian grouping: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:key name="by-genre" match="book" use="genre"/> <xsl:template match="/"> <xsl:for-each select="catalog/book[generate-id() = generate-id(key('by-genre', genre)[1])]"> <xsl:sort select="count(key('by-genre', genre))" data-type="number" order="descending"/> <xsl:value-of select="concat(genre, ' - ', count(key('by-genre', genre)), ' ')"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
