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

grouping adjacent siblings

Subject: grouping adjacent siblings
From: utah@xxxxxxxxxxxxxxx
Date: Thu, 3 May 2001 11:48:27 -0400 (EDT)
ingersoll utah
I am trying to transform the following...

<frag>
 <b>house</b>
 <a>door</a>
 <a>wall</a>
 <a>room</a>
 <b>barn</b>
 <a>hay</a>
 <a>cow</a>
 <a>poo</a>
</frag>

into...

<frag>
 <house>
  <a>door</a>
  <a>wall</a>
  <a>room</a>
 </house>
 <barn>
  <a>hay</a>
  <a>cow</a>
  <a>poo</a>
 </barn>
</frag>

using something to the effect of...

<xsl:template match="frag">
 <xsl:for-each select="b">
  <xsl:apply-templates/>
  <xsl:for-each
select="following-sibling::a[not(following-sibling:*[1][self::b)]">
   <xsl:apply-templates/>
  </xsl:for-each>
 </xsl:for-each>
</xsl:template>

which is a long way off...
I want to stick to defining the pattern within one template (preferably
within one XPath expression) for I have a lot of tricky nested nodes to
knock out and the source tree to get at this context node...
I've had some luck at grouping all following <<a>> siblings into their
respective <<b>> context node but have been unable to replicate this with
preceding nodes. If possible this woudl seem to be the simplest
solution...

1. select all following nodes
2. exclude all nodes preceding the context node

But this would require back-referencing the *current* context node..
right??
any ideas...

Utah Ingersoll
utah@xxxxxxxxxxxxxxx


 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.