xsl-list
[Top] [All Lists]

Re: [xsl] Select a node only if its previous siblings have specific attributes

2011-04-16 13:38:26
Works like a charme Brandon! Thanks!

On Fri, Apr 15, 2011 at 8:44 PM, Brandon Ibach
<brandon(_dot_)ibach(_at_)single-sourcing(_dot_)com> wrote:
I'm not sure I'm completely clear on your requirement, but try this:

//data[@result = '9'][not(preceding-sibling::data[@result != '10' and
@result != '11'])][last()]

-Brandon :)


On Fri, Apr 15, 2011 at 1:40 PM, Philipp Kursawe 
<phil(_dot_)kursawe(_at_)gmail(_dot_)com> wrote:
Hello,

a node with @result='9' should be select if one of its previous
siblings has @result=10 or @result=11. Only the most recent node with
@result=9 should be selected.

given the following examples:

<root>
<data result="11"/>
<data result="10"/>
<data result="9"/>
</root>
Should select data[3]

<root>
<data result="11"/>
<data result="5"/>
<data result="9"/>
</root>
Should not select any node, because one of data[3] prev siblings has
@result != 10|11

<root>
<data result="11"/>
<data result="9"/>
<data result="5"/>
<data result="9"/>
</root>
Should select data[2] not data[4] because data[4] has previous
siblings with @result != 10|11

How would the XPath selector look like? Basically i need to find the
first() (or last()?) node whose previous siblings do not have
@result=10|11

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>
--~--

<Prev in Thread] Current Thread [Next in Thread>