|
Subject: RE: [xsl] Sorting an xml From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 23 May 2006 09:29:17 +0100 |
In XSLT 2.0, with shopinglist as the context item:
<xsl:for-each-group select="item" group-by="place">
<xsl:value-of select="current-grouping-key()"/>:
<xsl:for-each select="current-group()">
<xsl:value-of select="count, unit, place"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each-group>
(You said you wanted the output sorted, but your specimen output was grouped
without sorting).
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Jimmy Ehs [mailto:jimmyahs@xxxxxxxxx]
> Sent: 22 May 2006 15:48
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Sorting an xml
>
> Hi, I'm making an application that makes a shopinglist, my
> XML might looks like this:
>
> --------------------------------------------------------------
> <shopinglist>
> <item>
> <name>Lax</name>
> <count>8</count>
> <unit>st</unit>
> <place>Kyl och frys</place>
> </item>
> <item>
> <name>Chalottenlvk</name>
> <count>4</count>
> <unit>st</unit>
> <place>Frukt och grvnt</place>
> </item>
> <item>
> <name>Matlagningsvin</name>
> <count>0,66</count>
> <unit>l</unit>
> <place>Vvrigt</place>
> </item>
> <item>
> <name>Grddde</name>
> <count>1,2</count>
> <unit>l</unit>
> <place>Kyl och frys</place>
> </item>
> </shopinglist>
> ----------------------------------------------------------
>
> The printout for this should be sorted by <place> like this:
> Kyl och frys:
> Lax 8 st
> Grddde 1,2 l
>
> Frukt och grvnt:
> Chalottenlvk 4 st
>
> Vvrigt:
> Matlagningsvin 0,66 l
>
>
>
> How do I do this as easy as possible?
> Thnx in advance!
> Jimmy
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Sorting an xml, Jimmy Åhs | Thread | [xsl] Evaluation of predicates (pot, Buchcik, Kasimier |
| [xsl] using every inside a predicat, Kevin Bird | Date | Re: [xsl] using every inside a pred, andrew welch |
| Month |