I think I mis read your requirement. the code I posted works so long as
there is at most one node with test="yes. If you have multiple such
nodes and need to select the preceding cousin of all of them,
Then...
//CELL[(_at_)test='yes']/../preceding-sibling::ROW[1]/CELL[position()=count(../following-sibling::ROW[1]/CELL[(_at_)test='yes']/preceding-sibling::CELL)+1]
David
<ROWS>
<ROW>
<CELL id="a"/>
<CELL id="b"/> <!-- select this and only this-->
<CELL id="c"/>
</ROW>
<ROW>
<CELL/>
<CELL test="yes"/>
<CELL/>
</ROW>
<ROW>
<CELL/>
<CELL/>
<CELL/>
</ROW>
<ROW>
<CELL id="aa"/>
<CELL id="bb"/> <!-- select this and only this-->
<CELL id="cc"/>
</ROW>
<ROW>
<CELL/>
<CELL test="yes"/>
<CELL/>
</ROW>
<ROW>
<CELL/>
<CELL/>
<CELL/>
</ROW>
</ROWS>
<xsl:template match="/">
<xsl:copy-of
select="//CELL[(_at_)test='yes']/../preceding-sibling::ROW[1]/CELL[position()=count(../following-sibling::ROW[1]/CELL[(_at_)test='yes']/preceding-sibling::CELL)+1]"/>
</xsl:template>
</xsl:stylesheet>
$ saxon count.xml count.xsl
<?xml version="1.0" encoding="utf-8"?><CELL id="b"/><CELL id="bb"/>
--~------------------------------------------------------------------
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>
--~--