This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Referencing value of non-sibling node
- From: Kim <kimba_40 at yahoo dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 3 Apr 2002 23:34:45 -0800 (PST)
- Subject: [xsl] Referencing value of non-sibling node
- Reply-to: xsl-list at lists dot mulberrytech dot com
Sample Input File segment:
<md>
...
<mi>
...
<mt>mtVal1</mt>
<mt>mtVal2</mt>
<mt>mtVal3</mt>
<mt>mtVal4</mt>
<mt>mtVal4</mt>
<mv>
<moid>moidVal1</moid>
<r>rVal1</r>
<r>rVal2</r>
<r>rVal3</r>
<r>rVal4</r>
<r>rVal5</r>
</mv>
</mi>
...
<mi>
<mt>mtVal11</mt>
<mt>mtVal12</mt>
<mv>
<moid>moidVal1</moid>
<r>rVal11</r>
<r>rVal12</r>
</mv>
</mi>
...
</md>
Note(s):
The <mt> and <r> Val pairs can occur within a <mi> node up to 500 instances.
Question:
Basically, the order of tests I need to do is the following:
1 - first match the <moid> value
2 - second match a specific <mt> value
3 - print out the matched <mt> value's corresponding <r> value.
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.
Here's a segment of the current xsl I am using:
<xsl:param name="parm_1"></xsl:param>
<xsl:param name="parm_2"></xsl:param>
=============================================================================
<xsl:apply-templates select="md"/>
</xsl:template>
<xsl:template match="md">
<xsl:apply-templates select="mi"/>
...
<xsl:apply-templates select="mv/moid"/>
</xsl:template>
<xsl:template match="moid">
NNN moid node
<xsl:variable name="moidVal" select="concat(';',.,';')"/>
<xsl:if test="contains($parm_1,$moidVal)">
AAA check mt matching val
<xsl:value-of select="."/>
<xsl:apply-templates select="../../mt"/>
</xsl:if>
</xsl:template>
<xsl:template match="mt">
<xsl:with-param name="moid"/>
<xsl:choose>
<xsl:when test="contains($parm_2,';all;')">
<xsl:apply-templates select="$parm_1"/>
AAA print all mts
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="mtVal" select="concat(';',.,';')"/>
NNN mt node
<xsl:if test="contains($parm_2,$mtVal)">
<xsl:value-of select="."/>
HOW TO PRINT CORESPONNDING rVal HERE?
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Thanks,
=====
Kim
*************************
May the force be with you.
*************************
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list