[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using preceding-sibling::node()
Hi Dilip,
At 02:28 PM 11/1/2004, you wrote: Hi, Sounds fine, up to the point where you say you want the preceding sibling of a node that doesn't exist ... XSLT isn't smart enough to know where in the input a node would be if it existed. For example: That's correct. Yet if your nodes are already ordered by time (which assumption is built into your question), you can get the last of this set in document order by grouping the set and using a predicate on the group. The last() function, which returns the size of the group, is designed for use in exactly this kind of situation. Using the query you've constructed (while removing that second, redundant predicate and changing '<' to '<=' in case that exact timestamp exists after all), that would be (child::data[attribute::id = 'archive']/child::timestamp[attribute::time <= '1099119599'])[position() = last()] or abbreviating this: (data[@id = 'archive'][@id='archive']/timestamp[@time <= '1099119599'])[last()] Cheers, Wendell
|
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
|