[xsl] $variables with xsl:key()

Subject: [xsl] $variables with xsl:key()
From: Steve <subsume@xxxxxxxxx>
Date: Mon, 24 Jul 2006 13:41:48 -0400
The below represents my attempts to create a table which looks something like

Cognitive  --- 26
Hearing    --- 17
*type3*  --- X

X = times which a disability of type=type3 appears in
$vP2/Records/Record as disabPrimary

My understanding of key breaks down somewhere. If you see what I am
doing wrong, please let me know.

Thanks,

-Steve

-------------------------------------------------------
XSL version = 1.0

XSL------------

<xsl:template match="/" >
	<xsl:apply-templates select="document('../../Consumer.xml')/disabilities" />
	<table>
	<xsl:for-each select="document('../../Consumer.xml')/disabilities/option[generate-id(.)=generate-id(key('options',@type)[1])]">
		<xsl:sort select="@type"/>
		<xsl:apply-templates mode="x" select="$vP2/Records">
			<xsl:with-param name="type" select="@type" />
		</xsl:apply-templates>
	</xsl:for-each>
	</table>
</xsl:template>

<xsl:template match="Records" mode="x">
	<xsl:param name="type" />
	<tr>
		<td>
			<xsl:value-of select="$type" />
		</td>
		<td>
			<xsl:value-of select="count(key('oldID',Record))" />
		</td>
	</tr>
</xsl:template>

Variable $vP2 contains via document()-----------

<Records>
   <Record>
         <disabPrimary>101</disabPrimary>
    </Record>
    <Record>
         <disabPrimary>201</disabPrimary>
    </Record>
    <Record>
         <disabPrimary>151</disabPrimary>
    </Record>

.....etc

And consumer.xml disabilties are like----------

<option oldID="413" type="Physical" name="Cancer"/>
<option oldID="400" type="Cognitive" name="Cerebral Palsy"/>
<option oldID="410" type="Physical" name="Chronic Fatigue Syndrome"/>
<option oldID="305" type="Cognitive" name="Cognitive-Other"/>

Current Thread