[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: preceding sibling headaches
> I thought that once you used a predicate ([1]), you couldn't go > any further in detail. A lot of people imagine that. I've no idea why. Applying predicates to intermediate steps in a path expression is one of the most powerful techniques in XPath. test="preceding-sibling::*[1]/self::transition" works as follows: 1. Select all the preceding sibling elements 2. Select the first of these 3. Select this node if it is a transition element, or nothing if not 4. Convert the result to a boolean: true if the node-set selected in (3) is non-empty I usually write this one as test="preceding-sibling::*[1][self::transition]" but the result is the same. Avoid tests like name()='transition' if you can. They are likely to be more expensive, and are less resilient to your choice of namespace prefixes in the source document. The only time to use them is when testing against a variable, e.g. name()=$param, and ideally you should then test local-name() and namespace-uri() rather than testing name(). Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx 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
|