Dear Artur,
Your XML is not well formed because the id attribute value is not in
quotes.
for example,
<elem id=1>
should have been
<elem id="1">
That said,
try the following code.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="elems">
<elems>
<xsl:for-each select="elem[not(@id = preceding-sibling::elem/@id)]">
<xsl:variable name="elem-id" select="@id"/>
<elem id = "{$elem-id}">
<xsl:for-each select="/elems/elem[(_at_)id = $elem-id]">
<xsl:copy-of select="*"/>
</xsl:for-each>
</elem>
</xsl:for-each>
</elems>
</xsl:template>
</xsl:stylesheet>
HTH
Vasu
----- Original Message -----
From: "Artur Matysiak" <majffa(_at_)yahoo(_dot_)com>
To: <XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, December 02, 2002 3:48 PM
Subject: [xsl] how to group nodes by id?
hi
does anybody know how to convert the following XML:
<elems>
<elem id=1>
<elem id=1/>
</elem>
<elem id=1>
<elem id=2/>
</elem>
<elem id=2>
<elem id=1/>
</elem>
<elem id=2>
<elem id=2/>
</elem>
</elems>
to the form
<elems>
<elem id=1>
<elem id=1/>
<elem id=2/>
</elem>
<elem id=2>
<elem id=1/>
<elem id=2/>
</elem>
</elems>
thanks Artur
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list