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

RE: Grouping of Tags

Subject: RE: Grouping of Tags
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Sat, 21 Jun 2003 11:38:28 +0100
following sibling first
Hi.

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Marc Baumgartner
> Sent: Friday, June 20, 2003 12:53 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Grouping of Tags
> 
> 
> Hello Everybody,
> 
> I have got a little problem with my Stylesheet.
> In my XML I have two types of tags. My result should be a 
> table where I want 
> for every block of the first tag a new row which contains all 
> the following 
> second tags.
> 
(...)
> Is this possbile with xsl? I haved tried this for several 

Sure. Try this:

<xsl:template match="root">
 <table>
  <!-- select all <first> that starts a new group, i.e., that doesn't have a
preceding-sibling or that the nearst preceding-sibling is a <second> -->
  <xsl:apply-templates select="first[not(preceding-sibling::*) or
preceding-sibling::*[1][self::second]]"/>
 </table>
</xsl:template>

<xsl:template match="first">
 <tr>
  <td><xsl:copy-of select="."/></td>
  <!-- first apply to the next consecutive <first> whose
following-sibling::second is the some of the current node  -->
  <xsl:apply-templates mode="next"
select="following-sibling::first[generate-id(following-sibling::second)=gene
rate-id(current()/following-sibling::second)]"/>
  <!-- then apply to the next consecutive <second> whose
following-sibling::first is the same of the first following-sibling::second
-->
  <xsl:apply-templates mode="next"
select="following-sibling::second[generate-id(following-sibling::first)=gene
rate-id(current()/following-sibling::second[1]/following-sibling::first)]"/>
 </tr>
</xsl:template>

<xsl:template match="first | second" mode="next">
 <td><xsl:copy-of select="."/></td>
</xsl:template>

Hope this helps you.



 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.