[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to select nodes between nodes

Subject: Re: how to select nodes between nodes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 15 Jan 2002 10:06:10 +0000
current following sibling
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.