Because sometimes the <fig> elements are nested below the others. That is why I
am using the "preceding" axis.
-----Original Message-----
From: Dimitre Novatchev dnovatchev(_at_)gmail(_dot_)com
[mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com]
Sent: Friday, February 27, 2015 3:58 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] preceding with the same ancestor as self
How can I restrict the preceding axis so a found node will have the
same ancestor as the context node? Thanks.
Why don't you use the "preceding-sibling::" axis instead?
Cheers,
Dimitre
On Fri, Feb 27, 2015 at 12:44 PM, Rick Quatro rick(_at_)rickquatro(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Hi,
When I am at a <fig> with no text, I want to find the previous <fig>
that has text, but only within the same ancestor group.
I am using this:
preceding::fig[.!=""][1]
This works for all of the empty <fig> elements in the first <grp>, but
in the second <grp>, it incorrectly picks up the <fig> with the 4
value from the previous <grp>. How can I restrict the preceding axis
so a found node will have the same ancestor as the context node? Thanks.
Rick
<?xml version="1.0" encoding="UTF-8"?> <doc>
<grp>
<fig/>
<fig>1</fig>
<fig>2</fig>
<fig/>
<sub>
<fig>3</fig>
</sub>
<fig/>
<fig>4</fig>
</grp>
<grp>
<fig/>
<fig>1</fig>
<fig>2</fig>
<fig>3</fig>
<sub>
<fig/>
</sub>
<fig/>
</grp>
</doc>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--