[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: preceding with the same ancestor as self

Subject: Re: preceding with the same ancestor as self
From: "Rick Quatro rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 27 Feb 2015 20:52:43 -0000
Re:  preceding with the same ancestor as self
I think I have it:

preceding::fig[.!="" and ancestor::grp = current()/ancestor::grp][1]

-----Original Message-----
From: Rick Quatro rick@xxxxxxxxxxxxxx
[mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx] 
Sent: Friday, February 27, 2015 3:44 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  preceding with the same ancestor as self

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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.