xslt - How to find ancestor-or-self that is a child of an element with particular attribute? -
i'm working generic xml structure, item (well relevant question anyway).
based on knowing item element i'm on , item element parent of node i'm looking for, need find item. have working xpath, it's resource intensive , i'm looking more elegant , cheaper.
the item key=a node parent of element i'm looking (though it's not child of document root)
xml:
<root> <item key="a"> <item key="b"> <item key="c"> <item key="d"/> </item> </item> <item key="e"> <item key="f"> <item key="g"/> </item> </item> </item> </root> the actual xml deeper , far more branching.
so instance, if i'm on item key=g, e or f need return item key=e. if i'm on item key b,c or d need return item key=b.
i'm using xpath, working, going , down ancestor-descendant axis seems far longer trip need.
current() /ancestor-or-self::item[@key='a'] /item[descendant-or-self::* = current()] is there simpler way of doing this, bearing in mind know 1) node i'm on , 2) key attribute of parent of node i'm looking for?
just detail's sake: xml sitecore generated, i'm not using current() function, i'm using sc_currentitem parameter set start node need begin processing at.
thanks in advance.
use:
ancestor-or-self::*[parent::item[@key='a']]
Comments
Post a Comment