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

Re: ancestor:: but to a point?

Subject: Re: ancestor:: but to a point?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Mar 2009 22:21:43 -0400
Re:  ancestor::  but to a point?
At 2009-03-10 21:18 -0500, Russ Urquhart wrote:
Our document structure is similar to Docbook, but NOT identical.

Our table structure is like the following:

<GenTable>
   <Title>
   <table>
      <tbody>
        <row>
           <entry role="">

when an <entry> element has its role attribute equal to hdr, i would
like to get the <GenTable>  element that contains that <entry>.  I
know that i can get the entry elements via //entry[@role='hdr'] but
is there a way to use ancestor: but only go as far up at <GenTable>,
and not all the way up to the root?

When your current node is at the <entry> element ...


select="ancestor::GenTable[1]"

... will address the *closest* ancestor <GenTable> element. This is because in XPath the ancestor axis addresses its nodes in reverse document order, and the [1] predicate is addressing the first in that order.

Trying to get my head fully around Xpath!

Doing so is worth the effort!


I hope this helps.

. . . . . . . . . . . Ken


-- XQuery/XSLT training in Prague, CZ 2009-03 http://www.xmlprague.cz XQuery/XSLT/XSL-FO training in Los Angeles (New dates!) 2009-06-08 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

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.