Re: [xsl] sorting based on variable and limit the results

Subject: Re: [xsl] sorting based on variable and limit the results
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sun, 22 Mar 2009 23:40:22 GMT
> is it possible to sort based on xsl:variable? If so, how?
yes but xsl:sort needs to be the first child of for-each.

In xslt2 you can use the content of xsl:sort rather that a select
attribute which allows a wider range of constructs. You didn't say
if you wanted xslt 1 or 2.


But you don't need a variable  you could do

<xsl:key name="p" match="p" use="pp"/>
....


<xsl:for-each select="//s">
  <xsl:sort select="count(key('p',n))"/>
  <tr><td><xsl:value-of select="n"/></td>
      <td><xsl:value-of select="count(key('p',n))"/></td></tr>
</xsl:for-each>

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread