This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Selecting specific ancestory by relation and name
- To: "'XSL-List'" <XSL-List at mulberrytech dot com>
- Subject: Selecting specific ancestory by relation and name
- From: "Eliot, Topher" <Christopher_Eliot at jdedwards dot com>
- Date: Mon, 9 Oct 2000 16:04:50 -0600
- Reply-To: xsl-list at mulberrytech dot com
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@jdedwards.com
303 334-2493
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list