|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Selecting specific ancestory by relation and name
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








