RE: [xsl] nested for-each on disjoint node sets & variable scope

Subject: RE: [xsl] nested for-each on disjoint node sets & variable scope
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 20 Jul 2009 23:35:37 +0100
The variable reference $oneRow looks OK to me.

I'm afraid it's not clear to me what you're trying to do or what problems
you are having. You don't show your input, you don't say what output you
want, you only show part of your code, and you don't say how it fails.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 
 

> -----Original Message-----
> From: Dick Penny [mailto:d_penny@xxxxxxx] 
> Sent: 20 July 2009 23:19
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] nested for-each on disjoint node sets & variable scope
> 
> I am trying sub-set my input rows and output the count of 
> rows per sub-set into a table such that the sub-sets are 
> mutually exclusive and collectively exhaustive. I use temp 
> node-sets to drive the sub-set production as per below.
> 
> I am reasonably far along for a novice but realize I don't 
> fully understand MK's table of variable scope. I believe in 
> code below that $oneRow has gone out of scope in the 2nd 
> for-each but I don't know what to do about it. Since I will 
> be adding a 3rd and 4th dimension of sub-setting, I'd like to 
> get the structure correct. I know the td's and tr's are 
> messed up, am not worried.
> 
> <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
> 
> <xsl:variable name="D1">
> 	<group>CRA</group>
> 	<group>HR</group>
> 	<group>Legal</group>
> </xsl:variable>
> 
> <xsl:variable name="D2">
> 	<src>Other</src>
> 	<src>EC_MailBox</src>
> 	<src>AlertLine</src>
> </xsl:variable>
> 
> <xsl:template match="/">
> 
> <table>
>     <tr><th>Col 1</th><th>Col 2</th>
>     </tr>
>     
>     <tr>
> <xsl:for-each select="msxsl:node-set($D1)/group">
> 	<xsl:variable name="d1" select="."/>
> 	<xsl:variable name="oneRow" select="$Rows[@GroupAssigned=$d1]"/>
> 	<td><xsl:value-of select="." /></td>
> 		
> 	<xsl:for-each select="msxsl:node-set($D2)/src">	
> 		<xsl:variable name="d2" select="."/>	
> 		<xsl:call-template name="oneCell">
> OUT-OF-SCOPE?		<xsl:with-param name="cnt"
> select="count($oneRow[@Source=$d2])"/>
> 		</xsl:call-template>	
> 	</xsl:for-each>	
> 		
> 	<td><xsl:value-of select="count($oneRow)" /></td> 
> </xsl:for-each>
> 
> Dick Penny

Current Thread