[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: select immediately following siblings with constr
Jim,
At 01:54 PM 2/23/2006, you wrote: Thank you very much for the reply. I actually hadn't been aware of the << and >> operators, I shall have to read up on them. Yes, they're fun, and ought to be useful for all kinds of neat things we haven't discovered yet. I did think about using a for loop, I just wasn't sure how I could write one which would be efficent, which wouldn't end up taking a lot more time than necessary to run down the remaining following-sibling elements. Note my attempt with the "for" expression (which actually isn't a loop but a mapping operation over a sequence, here applied to fake a "let" rather than perform a mapping :-) won't catch following sibling a elements when there is no following sibling b, so you'd have to add such following sibling a elements explicitly, for completeness. Thus: ((for $b in following-sibling::b[1] return following-sibling::a[. << $b]), (following-sibling::a[not(current()/following-sibling::b)])) ... which is even less orthodox than ever. Without the current() function you have to do ((for $b in following-sibling::b[1] return following-sibling::a[. << $b]), (for $s in . return following-sibling::a[not($s/following-sibling::b)])) I just tried this; amazingly enough it seems to work. It remains a good question how much of this work should be done in XPath. I think the XSLT side is often easier to work with even if it's more verbose. As for efficiency, being blissfully ignorant of most of what happens under the covers, I generally don't worry too much about that; but I doubt this would be a problem in most documents. (It might be in one that was unusually long and flat.) My general attitude is that performance is never a problem until it actually is one. Which of the XPath or XSLT approaches would create more of an impression of wizardry, I leave for you to consider. :-> Cheers, Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
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
|