Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Sorting by count() in a for-each [Thread Next] Re: Sorting by count() in a for-eachTo: NULL Date: 4/1/2007 9:16:00 PM On Apr 1, 2:42 pm, nasser.alhi...@gmail.com wrote: > Hi there, > I've been trying to get the "apply-templates" to sort the output and > only show 5 items of the result sorted by count. I'm not able to do > so. All i get are all the results which aren't sorted. Any insight > would be much much appreciated. Thanks! > ~Nas Good Morning! Pardon me, the XML is a little large ill try to snip out most irrelevant info ---------- all.xml -------------- <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="patches.xsl"?> <Scan UIScan="" Session="70845075" Profile="Missing Patches"> <hosts> <host visible="1"> <hostname>SERVER1</hostname> ... ... <hotfixes> <product> <hotfix> ... ... ... </hotfix> <hotfix> ... ... ... </hotfix> </product> </hotfixes> <alerts> <missing_hotfixes> <product name="Exchange"> <hotfix> ... ... ... </hotfix> <hotfix> ... ... ... </hotfix> </product> <product name="Windows"> <hotfix> ... ... ... </hotfix> <hotfix> ... ... ... </hotfix> </product> </missing_hotfixes> </alerts> </host> </hosts> </Scan> --------------------------------- --------- patches.xsl ----------- ?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform"> <xsl:template match="hotfixit"> <xsl:if test="position() >= 5"> <xsl:copy-of select="."/> </xsl:if> </xsl:template> <xsl:template match="/"> <html> <head><title></title></head> <body> <table border="1"> <thead> <td>Server</td> <td>Patches Missing</td> </thead> <tbody> <xsl:for-each select="/Scan/hosts/host"> <xsl:apply-templates select="hotfixit"> <xsl:sort select="count(alerts/missing_hotfixes/product/hotfix)" data-type="number" order="descending"/> </xsl:apply-templates> <tr> <td><xsl:value-of select="hostname"/></td> <td><xsl:value-of select="count(alerts/missing_hotfixes/product/ hotfix)"/></td> </tr> </xsl:for-each> </tbody> </table> </body> </html> </xsl:template> </xsl:stylesheet> --------------------------------- The output doesn't sort out, and neither does it (the apply-templates tag) display only 5 items, it seems to get ignored. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
