|
[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
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
|
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








