FW: [xsl] is it possible to access the previous context()

Subject: FW: [xsl] is it possible to access the previous context()
From: Don Bruey <dbruey@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Mar 2001 12:47:16 -0500
Okay, so @type isn't in the Filters element, but idea still holds. 

Don


-----Original Message-----
From: Don Bruey 
Sent: Thursday, March 15, 2001 12:45 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE: [xsl] is it possible to access the previous context()


If I understand what you're looking for you can create a variable before
entering the inner for-each with the attribute value you want.

for example:


   <xsl:for-each select ="/root/Data/Filters">
	<xsl:variable name="outerType" select="@type" />
	<xsl:for-each select="Filter">
		<td>
			compare $outerType to whatever in here
		</td>
	</xsl:for-each>
   </xsl:for-each>

Then in the inner loop you can compare the values of the attribute in the
current for-each context with the variable that was created within the outer
for-each.  


Don




-----Original Message-----
From: Vladimir.Stanishev@xxxxxxxxxxxxxxxxxxx
[mailto:Vladimir.Stanishev@xxxxxxxxxxxxxxxxxxx]
Sent: Thursday, March 15, 2001 12:29 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] is it possible to access the previous context()


Hi all. 
Is it possible to access the previous context in nested <xsl:for-each>
loops.   

for example if my xml file is:

<root>
	<FilterTypes>
		<FilterType type="red"/>
		<FilterType type="green"/>
		<FilterType type="orange"/>
		<FilterType type="blue"/>	
	</FilterTypes>
	<Filters>
		<Filter>
			<Name>Not Shiny</Name>
			<Value>blah</Value>
			<FitlerType type="red" value="34"/>
			<FitlerType type="blue" value="87"/>
		</Filter>
		<Filter>
			<Name>Shiny</Name>
			<Value>other</Value>
			<FitlerType type="green" value="12"/>
			<FitlerType type="orange" value="13"/>
			<FitlerType type="blue" value="15"/>
		</Filter>
	</Filters>
</root>

I am trying to do the following:

<table>
<xsl:for-each select="/root/FilterTypes/FilterType">
  <tr>
   <xsl:for-each select ="/root/Data/Filters">
	<xsl:for-each select="Filter">
		<td>here I want to display the @value attribute for the
FilterType element of the current Filter where the @type attribute is equal
to the @type attribute of the current /root/FilterTypes/FilterType in the
context of the outermost for loop. ugh.  even I get confused by this
sentence but it's right, that's what I am trying to do. 
		</td>
	</xsl:for-each>
   </xsl:for-each>
  </tr>
</xsl:for-each>
</table>

the output I am looking for is the following:

		Not Shiny		Shiny
red		  34			Nan
green		NaN			12
orange		NaN			13
blue		 87			15

I am not sure if this is possible the way the xml file is structured. 
Thanks in advance any help is really appreciated.  

Vladimir.  


----------------------------------------------------------------------------
----------
For more information about Barclays Capital, please
visit our web site at http://www.barcap.com.


Internet communications are not secure and therefore the Barclays Group
does not accept legal responsibility for the contents of this message.
Any views or opinions presented are solely those of the author and do 
not necessarily represent those of the Barclays Group unless otherwise 
specifically stated.

----------------------------------------------------------------------------
----------

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread