xsl-list
[Top] [All Lists]

[xsl] $variables with xsl:key()

2006-07-24 10:42:08
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"/>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>