|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: how to group nodes by id?
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[@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@xxxxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, December 02, 2002 3:48 PM
Subject: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








