Frank Marent wrote:
david, abel
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]
it's always a good feeling among xml-giants... i was posting the point
you've detected yourself - and abel. your statement reads for me like:
//CELL[(_at_)test='yes']magic()/but()/it()/works()/halleluja()/preceding-sibling::CELL)+1]
:))
Note that I tried to correct David with removing the '+1' with a
self-test. But that's not needed. David's last solution is perfect and
comes down to about the same I invented (it almost looked like David and
I were in the same room: even the sample input and test template about
matched!), but mine is a bit overly complicated.
(the reason that you can use +1 safely is that you are already walking
from the path CELL[(_at_)test='yes'], which means that once the path matches,
you are certain the +1 is correct)
About the 'magic', I usually do a mind-treewalk while dissecting a path.
I imaging being some place on the XML tree and then walk the steps I
wrote down in the XPath. Then suddenly the 'magic' goes and it all seems
so logical.
Cheers,
-- Abel
--~------------------------------------------------------------------
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>
--~--