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

Referencing value of non-sibling node

Subject: Referencing value of non-sibling node
From: Kim <kimba_40@xxxxxxxxx>
Date: Wed, 3 Apr 2002 23:34:45 -0800 (PST)
xsl value of select sibling
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


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.