[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Put a wrapper around a series o, Miloslav Nic | Thread | using <,>,&& in XSL, Subin Thampi |
RE: Saxon and validating, Kay Michael | Date | RE: XML and text declarations (was , Kay Michael |
Month |