|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: the nearest ancestor with the attribute
Hello Guai,
ancestor::*[@attr] gets you the ancestors with the 'attr' attribute, from nearest to furthest ancestor::*[@attr][1] gets you the first of these ancestor::*/@attr gets you the attribute nodes themselves (from nearest to furthest) this is often good enough, because if (for example), you ask for the value of this node set, you'll get the value of the first one (the nearest) ancestor::*/@attr[normalize-space(.)] gets you the same set, only excluding all attributes from the list that have no value or a whitespace-only value the trick is, however, that ancestor::*/@attr[1] won't get the nearest attr attribute, but the whole set this is because [position()=1] will test true for any attribute (won't it?) if you want to filter the nodes so only the attribute on the nearest ancestor with the attribute is returned, you have to do (ancestor::*/@attr)[last()] This takes the node set of all the attr attributes on all ancestors, groups them in document order, and takes the last in the list. This will be the nearest. Hope that helps! Wendell At 01:45 PM 1/15/01 -0800, you wrote: How could I get the nearest ancestor with a certain attribute, say "attr"?
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
|

Cart








