This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Referencing value of non-sibling node
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Kim <kimba_40 at yahoo dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Sat, 6 Apr 2002 18:23:23 +0100
- Subject: Re: [xsl] Referencing value of non-sibling node
- Organization: Jeni Tennison Consulting Ltd
- References: <20020404073445.81747.qmail@web10906.mail.yahoo.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Kim,
> My specific question is when I have matched a <moid> and also
> matched a <mt> value, how do I specify/reference the corresponding
> indexed <r> value? In the example above, if I match <mt>mtVal4, the
> fourth element, I would also print out the fourth <r>rVal4 value.
>From what I can tell, each <mt> is associated with a particular <r>
based on its position, so the first <mt> in a <mi> is related to the
first <r> within the <mv> of that <mi>, the second <mt> with the
second <r> within the <mv> of the <mi> and so on. Is that accurate?
If so, then in your template matching the <mt> element, you have to
first find out the index of the <mt> within the <mi>. Now, you're
actually applying templates to these <mt> elements in order, so this
is quite easy -- all you have to do is store the position() of the
current <mt> element in a variable:
<xsl:variable name="index" select="position()" />
and then use that index to find the <r> element within the <mt>
element's parent <mi> element's child <mv> element with the same
position:
<xsl:value-of select="parent::mi/mv/r[$index]" />
If that isn't what you were after, give us a more detailed description
of what the "corresponding <r>" means.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list