xsl-list
[Top] [All Lists]

Re: [xsl] How to select an attribute on the current node or its anchestor

2011-04-15 10:03:24
You guys are amazingly quick!
Thanks a lot!

Lets see if the old msxml on Windows CE 6.0 understands that :)

Phil

On Fri, Apr 15, 2011 at 10:26 AM, Michael Kay <mike(_at_)saxonica(_dot_)com> 
wrote:
On 15/04/2011 07:33, Brandon Ibach wrote:

ancestor-or-self::*[@data][1]/@data


Or if you prefer, (ancestor-or-self::*/@data)[last()]

Michael Kay
Saxonica


On Fri, Apr 15, 2011 at 2:06 AM, Philipp 
Kursawe<phil(_dot_)kursawe(_at_)gmail(_dot_)com>
 wrote:

Hello,

given the following xml:

<node data="foo">
  <text id="1" data="bar"/>
  <text id="2"/>
</node>

I would like to know the XPath expression to select @data which
results in "bar" for @id=1 and "foo" for @id=2.

The general idea is to search for the attribute in the anchestor if
the current node does not contain the attribute all the way up to the
root node.

Thanks for your help!

Phil

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or 
e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or 
e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--