Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] keys and variables VIII

From: Steve <subsume@--------->
To:
Date: 8/2/2006 5:42:00 PM
Hello list,



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

I am scoring for output that looks like: ==>
      <tr><td>Cognitive</td><td>50</td></tr>
      <tr><td>Physical</td><td>50</td></tr>
      <tr><td>Hearing</td><td>46</td></tr>
      <tr><td>Mental</td><td>50</td></tr>
      <tr><td>None</td><td>23</td></tr>

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" />
	<tr><td>
	        	<xsl:value-of select="$type" />
		</td>
                <td>
   	                <xsl:variable name="current" select="disabPrimary" />
       	        <xsl:for-each select="$Definitions">
       			<xsl:value-of select="count(key('oldID',$current))" />
              		</xsl:for-each>
   	</td></tr>
</xsl:template>

<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" />
		</xsl:apply-templates>
	</xsl:for-each>
</xsl:template>

Disab.xml ==>



<disabilities>
      <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
Retardation"/>
      <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"/>
</disabilities>

Records.xml ==>



<Records>
      <Record>
              <disabPrimary>200</disabPrimary>
      </Record>
      <Record>
              <disabPrimary>407</disabPrimary>
      </Record>
      <Record>
              <disabPrimary>419</disabPrimary>
      </Record>
      <Record>
              <disabPrimary>101</disabPrimary>
      </Record>
      <Record>
              <disabPrimary>101</disabPrimary>
      /Record>
      <Record>
              <disabPrimary>101</disabPrimary>
      </Record>
      <Record>
              <disabPrimary>101</disabPrimary>
      </Record>
      <Record>
              <disabPrimary>200</disabPrimary>
      </Record>
      <Record>
              <disabPrimary>101</disabPrimary>
      </Record>
   *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.*


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent