[xsl] XPath needed for getting the nearest attribute on the ancestor axis till a Node with a particular name() is found

Subject: [xsl] XPath needed for getting the nearest attribute on the ancestor axis till a Node with a particular name() is found
From: "Sanjay Pandey/Towers Perrin" <pandeys@xxxxxxxxxx>
Date: Wed, 22 Aug 2001 09:29:55 -0400
Hi list,

I needed to get the nearest attribute value (with name() 'name' or 'type'
or 'category') on the ancestor axis, starting from a particular node. I am
able to do that, thanks to this list too for that, using the following:
            xpathStr = "./ancestor::*[@name or @type or
@category][1]/@*[name() = 'name' or name() = 'type' or name()
= 'category']";
            XObject obj = XPathAPI.eval(currentNode,xpathStr);
It works fine. Now I want to limit the ancestor axis traversal till I find
a node with name() = 'someName', otherwise the search would continue till
root node.

Can this be done within the single XPath or I will need to do a loop where
I go one node up check if I have hit the node with 'someName', ifNot then
look for the relevant attribute?

Suggestions would be appreciated.

Thanks,
Sanjay



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread