Subject: Re: [xsl] number continuation problem From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 30 Jun 2003 17:50:02 +0100 |
Hi Andrew, > A new twist is that there can be many <elseif>'s to an <if> > (naturally enough), so the data can take the form: > > <if/> > <elseif/> > <elseif/> > <elseif/> > <if/> > <elseif/> > > Is there a neat trick of getting all following-siblings while they > are of a certain name (as if they are processed linearly). In XSLT 1.0, use a key: index all the <elseif> elements by their immediately preceding <if> element: <xsl:key name="elseifs" match="elseif" use="generate-id(preceding-sibling::if[1])" /> Then, when on an <if> element, you can get all the related <elseif> elements with: key('elseifs', generate-id(.)) Or you can just do it with: following-sibling::elseif[generate-id(preceding-sibling::if[1]) = generate-id(current())] Or you can step through them one-by-one recursively. Note that your solution: following-sibling::elseif[not(preceding-sibling::if[2])] collects together all the <elseif> elements that have 0 or 1 preceding sibling <if> elements. So, for example, if you're on the second <if> of the example above, it won't select the following <elseif> because it does have a second preceding sibling <if> element. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] number continuation probl, Andrew Welch | Thread | RE: [xsl] number continuation probl, Andrew Welch |
RE: [xsl] namespace change, what am, Lars Huttar | Date | Re: [xsl] xsl:sort in old MSXML, David Carlisle |
Month |