Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Advanced sort [Thread Next] Re: Advanced sortTo: NULL Date: 3/17/2009 7:42:00 PM Martin Honnen a pensé très fort :
> That data above is not what you posted initially.
Sure. It was just an example but it is the same way.
> Your stylesheet has the right approach with the key but I think it can be
> much shorter, at least for the data you posted originally:
>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:output method="xml" indent="yes"/>
>
> <xsl:key name="by-tag"
> match="tag"
> use="."/>
>
> <xsl:template match="/items">
> <tags>
> <xsl:apply-templates select="item/tags/tag[generate-id() =
> generate-id(key('by-tag', .)[1])]">
> <xsl:sort select="count(key('by-tag', .))" data-type="number"
> order="descending"/>
> </xsl:apply-templates>
> </tags>
> </xsl:template>
>
> <xsl:template match="tag">
> <tag id="{.}">
> <xsl:value-of select="count(key('by-tag', .))"/>
> </tag>
> </xsl:template>
>
> </xsl:stylesheet>
I'll try this sample, thanks.
Now, I've decided to provide data using Xml Web Services but the page
render will use Javascript + Xsl transformation.
--
Delf
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
