[xsl] keys and variables VIII

Subject: [xsl] keys and variables VIII
From: Steve <subsume@xxxxxxxxx>
Date: Wed, 2 Aug 2006 13:41:50 -0400
Hello list,

Having some difficulty with output. Perhaps someone can shed some
light as to why.

I am scoring for output that looks like: ==>

The number above indicates the amount of times a disability with an
oldID corresponding to the type in the first <td></td> appears in the
whole of /Record/Record

The existing problem output is at the bottom of this post for
readability purposes.

I've played around with this for hours but cannot get the output I
need. In other threads some suggested a two key nested solution but
I'm not sure if it is neccesary here.

Here's my code (tested and parsing) ==>

<xsl:variable name="Definitions" select="document('../../Disab.xml')" />
<xsl:variable name="vP2" select="document('../../Records.xml')" />
<xsl:key name="options" match="option" use="@type" />
<xsl:key name="oldID" match="option" use="@oldID" />

<xsl:template match="Record" mode="x">
	<xsl:param name="type" />
	        	<xsl:value-of select="$type" />
   	                <xsl:variable name="current" select="disabPrimary" />
       	        <xsl:for-each select="$Definitions">
       			<xsl:value-of select="count(key('oldID',$current))" />

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

Disab.xml ==>

      <option oldID="204" type="Cognitive" name="Alzheimer's/Dementia"/>
      <option oldID="407" type="Physical" name="Amputation"/>
      <option oldID="405" type="Physical" name="Arthritic Conditions"/>
      <option oldID="301" type="Cognitive" name="Autism"/>
      <option oldID="100" type="Visual" name="Blind"/>
      <option type="Physical" name="Blood disorders" />
      <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"/>
      <option type="Physical" name="Cystic Fibrosis"/>
      <option oldID="101" type="Hearing" name="Deaf"/>
      <option oldID="302" type="Cognitive" name="Developmental/Mental
      <option oldID="414" type="Physical" name="Diabetes"/>
      <option oldID="411" type="Physical" name="Epilepsy/Seizure Dis."/>
      <option type="Physical" name="Fibromyalgia"/>
      <option oldID="101" type="Hearing" name="Hard of Hearing"/>
      <option oldID="415" type="Physical" name="Heart Disease" />
      <option type="Physical" name="Hepatitus"/>
      <option oldID="416" type="Physical" name="HIV/AIDS"/>
      <option type="Physical" name="Kidney disorder/renal failure"/>
      <option oldID="300" type="Cognitive" name="Learning Disabilities">
      <option oldID="" type="Physical" name="Lung
disease/disorders/conditions" />
      <option oldID="202" type="Mental" name="Mental Health-Other"/>
      <option oldID="200" type="Mental" name="Mental Illness/Emot.Dis"/>
      <option oldID="418" type="Physical" name="Morbid Obesity"/>
      <option oldID="417" type="Physical" name="Multiple Chemical Sensitive"/>
      <option oldID="420" type="Multiple" name="Multiple Disability"/>
      <option oldID="403" type="Physical" name="Multiple Sclerosis"/>
      <option oldID="402" type="Physical" name="Muscular Dystophy"/>
      <option oldID="412" type="Physical" name="Neurological-Other"/>
      <option oldID="500" type="None" name="None"/>
      <option oldID="406" type="Physical" name="Orthopedic-Other"/>
      <option oldID="419" type="Physical" name="Physical-Other"/>
      <option oldID="410" type="Physical" name="Post-Polio"/>
      <option oldID="404" type="Physical" name="Spinal Cord Disorders" />
      <option oldID="404" type="Physical" name="Spinal Cord Injuries" />
      <option oldID="409" type="Physical" name="Stroke/Cardiovascular"/>
      <option oldID="201" type="Mental" name="Substance Abuse/Addiction"/>
      <option oldID="303" type="Cognitive" name="Traumatic Brain Injury" />
      <option oldID="" type="Visual" name="Visually Impaired"/>

Records.xml ==>

   *and so on for hundreds*

Right now I'm getting

Cognitive 	1
Cognitive 	2
Cognitive 	1
Cognitive 	2
Cognitive 	2
Cognitive 	1
Cognitive 	2
Cognitive 	2
Cognitive 	2
*and so on and so forth for many many many dozen lines.*

Current Thread