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

Selecting specific ancestory by relation and name

Subject: Selecting specific ancestory by relation and name
From: "Eliot, Topher" <Christopher_Eliot@xxxxxxxxxxxxx>
Date: Mon, 9 Oct 2000 16:04:50 -0600
ancestory
I want to get the value of a certain sibling of the current element, but
only if the current element's parent is of a certain type.  In other words,
suppose I'm creating the template for B elements.  My input XML may look
like (these are just fragments):

<A>
  <B/>
  <C>...</C>
</A>

<Z>
  <B>
  <C>...</C>
</Z>

In the first case, I want to pick up the value of C and put it into my
output stream (because the parent element is A); in the second case I do not
(because the parent element is Z, not A).  Note that the following is also
legal input:

<Y>
  <A>
    <B/>
    <C>...</C>
  </A>
  <A>
    <B/>
    <C>...</C>
  </A>
</Y>

Note that this means that I cannot just refer to "../../A/C" in the B
template, because I could end up getting the value from the wrong C element.

I am currently using

"ancestor::*[1][name()='A']/C"

Of course my names aren't 'A' and 'C'; in fact they're *VERY* long, so this
quickly gets unwieldy.

This sure seems clumsy.  For the elegant, intuitive, language that XSLT is
supposed to be, surely there's a simpler way to do this?  I've tried using
'..' and '/' until I'm blue in the face, and gotten nowhere.

Any help will be appreciated.

Topher Eliot
Sr. Software Engineer
J.D. Edwards
Christopher_Eliot@xxxxxxxxxxxxx
303 334-2493


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.