[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to group nodes by id?

Subject: Re: how to group nodes by id?
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Mon, 2 Dec 2002 16:26:45 -0000
majffa
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.