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

Subject: [xsl] nested for-each on disjoint node sets & variable scope
From: "Dick Penny" <d_penny@xxxxxxx>
Date: Mon, 20 Jul 2009 15:19:02 -0700
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