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 Åhs [mailto:jimmyahs(_at_)gmail(_dot_)com]
Sent: 22 May 2006 15:48
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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>Chalottenlök</name>
<count>4</count>
<unit>st</unit>
<place>Frukt och grönt</place>
</item>
<item>
<name>Matlagningsvin</name>
<count>0,66</count>
<unit>l</unit>
<place>Övrigt</place>
</item>
<item>
<name>Grädde</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
Grädde 1,2 l
Frukt och grönt:
Chalottenlök 4 st
Övrigt:
Matlagningsvin 0,66 l
How do I do this as easy as possible?
Thnx in advance!
Jimmy
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--