[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: how to select nodes between nodes
Hi Mario, > Thanx a lot for your answer. I tried it out and it seems to work. > Just if it interests u, i got another proposal that works (just > fancying which one I should use): The path that the other proposal uses is: following-sibling::*[count(. | current() /following-sibling::comma[1] /preceding-sibling::*) = count(current() /following-sibling::comma[1] /preceding-sibling::*)] The current()/following-sibling::comma[1] gets hold of the next comma (I bound this to the variable $next-comma in my suggestion). The current()/following-sibling::comma[1]/preceding-sibling::* gets *all* the elements preceding the next comma. This is likely to be quite a long list, so calculating this will be fairly inefficient if you've got a long document. You should definitely place it in a variable: <xsl:variable name="next-commas-preceding-elements" select="current()/following-sibling::comma[1]/preceding-sibling::*" /> That would make the expression: following-sibling::*[count(.|$next-commas-preceding-elements) = count($next-commas-preceding-elements)] This goes through every element following the current one and tests whether it is in the set of elements that precedes the immediately following sibling. The solution I suggested was: following-sibling::*[generate-id(following-sibling::comma[1]) = generate-id($next-comma)] (which could also have been written: following-sibling::*[count(following-sibling::comma[1] | $next-comma) = 1] ) This goes through every element following the current one and tests whether its following comma is the same as the next comma from this element. They'll both work. My guess would be that the first one would be slightly more efficient in a short document or where the commas are quite far apart, and that the second would be slightly more efficient in a long document or where the commas are quite close together. But probably the difference is so slight that it doesn't matter anyway - try them both out and see, if you actually care :) Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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
|