Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - selecting a range of nodes [Thread Next] Re: selecting a range of nodesTo: NULL Date: 8/3/2007 9:56:00 AM In article <joCsi.15392$7c.10352@f...>, Andy Fish <ajfish@b...> wrote: >I am trying to select a range of following siblings using xslt 1.0. consider >the following XML file > ><top> > <a1/> > <a2/> > <foo/> > <a3/> > <a4/> > <a5/> > <a6/> > <bar/> > <a7/> > <a8/> ></top> > >now, inside this template > ><xsl:template match="foo"> > >I would like to select all the nodes up to the following <bar> (if there are >several <bar>s it would be the next one) It's a bit messy. You want the following-siblings of the foo that have a following-sibling which is the first bar after the foo. So set a variable $bar to following-sibling::bar[1], and use following-sibling::*[generate-id(following-sibling::bar[1]) = generate-id($bar)] In this case generate-id works better than counting the union because some of the elements may not have a following bar element. For more complicated examples you might want to use "Muenchian grouping" (see Google). -- Richard -- "Consideration shall be given to the need for as many as 32 characters in some alphabets" - X3.4, 1963. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
