|
Subject: RE: [xsl] Top 100 rows and sort them? From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 5 Jun 2006 13:13:20 +0100 |
You need two phases: first sort by number, then by word. That means you
either need XSLT 2.0, or the XSLT 1.0 xx:node-set() extension, or two
stylesheets running in a pipeline.
In 2.0:
<xsl:variable name="sorted-by-number" as="element(row)*">
<xsl:perform-sort select="/root/row">
<xsl:sort select="xs:integer(number)" order="descending"/>
</xsl:perform-sort"/>
</xsl:variable>
<xsl:variable name="top-100" select="$sorted-by-number[position() le 100]"/>
<xsl:for-each select="$top-100">
<xsl:sort select="word"/>
<xsl:copy-of select="."/>
</xsl:for-each>
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Niklas Holmberg [mailto:Niklas.Holmberg@xxxxxxxxx]
> Sent: 05 June 2006 12:54
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Top 100 rows and sort them?
>
>
> hi!
> This is my xml (contains about 400 row elements):
> <root>
> <row>
> <word>Afrikanskt</word>
> <number>21</number>
> </row>
> <row>
> <word>Amerikanskt</word>
> <number>23</number>
> </row>
> </root>
> what i want to do is to pick the 100 elements that has the
> largest "number" and then print them out sorted by "word". is
> this possible to do at all with xsl?
> thanks!
> /niklas
>
>
>
>
> Confidentiality Notice: This e-mail transmission may contain
> confidential or legally privileged information that is
> intended only for the individual or entity named in the
> e-mail address. If you are not the intended recipient, you
> are hereby notified that any disclosure, copying,
> distribution, or reliance upon the contents of this e-mail is
> strictly prohibited and may be unlawful. If you have received
> this e-mail in error, please notify the sender immediately by
> return e-mail and delete all copies of this message.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Top 100 rows and sort the, David Carlisle | Thread | Re: [xsl] Top 100 rows and sort the, Dimitre Novatchev |
| Re: [xsl] Top 100 rows and sort the, David Carlisle | Date | Re: [xsl] Top 100 rows and sort the, David Carlisle |
| Month |