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

RE: Put a wrapper around a series of elements

Subject: RE: Put a wrapper around a series of elements
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Fri, 10 Nov 2000 13:13:47 -0000
xml wrapper around elements
This is a grouping problem: unlike the usual grouping problem you are
grouping by position rather than by value, but you can use the same
techniques.

Approach 1: write a recursive template all-the-bs with the following logic:

if $nodeset[1][self::b]
   copy-of $nodeset[1]
   call all-the-bs with-param nodeset = $nodeset[position()>1]

and call it to process the full nodeset
<bset>
  call-template all-the-bs
</bset>

Approach 2: use Muenchian grouping with a key defined as
<xsl:key match="b" use="generate-id(following-sibling::c[1])">

This means all b siblings with the same following <c> will have the same key
value.

Approach 3: (Saxon only)

saxon:leading(*, saxon:expression('self::b'))

Selects all nodes in "*" up to the first one for which self::b is false.

Mike Kay
   
  

> Have
> 
> <a>
>  <b>some text</b>
>  <b>some more text</b>
>  <b>some other text</b>
>  <b>some last text</b>
> <c>some c text</c>
> </a>
> 
> Want
> 
> <a>
>  <bset>
>   <b>some text</b>
>   <b>some more text</b>
>   <b>some other text</b>
>   <b>some last text</b>
>  </bset>
> <c>some c text</c>
> </a>
> 
> I successfully tested for the first and last <b>, but
> couldn't output unmatched elements. . .
> 
> Is there a better way?
> 
> 
>  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.