[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: For-each and keys()

Subject: Re: For-each and keys()
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 31 Jul 2006 17:43:21 +0100
xml xsl for each counting
On 7/31/06, Steve <subsume@xxxxxxxxx> wrote:
Hey group,

Trying to come up with key declarations for the below XML trees (which
are both contained within $variables

At the end of the day, I need output that resembles

        <output type="Cognitive"  count="50" />
        <output type="Physical"  count="26" />
        <output type="Visual"  count="34" />
        <output type="Hearing"  count="90" />
        <output type="Mental"  count="11" />
        <output type="None"  count="1" />

The count, in this case, is the amount of times a Record/disabPrimary
corresponds to any disabilities/option/@oldID.  These must then be
grouped by their @type and appear only once in the table.

Sorry to post so much but in trying to score for brevity I have
obviously overcorrected and gone straight to muddled ambiguity in
previous posts. Please let me know if there is anything too vague that
I may elaborate upon.

My current XSL has the problem of not using key in a meaningful way
(always returns 0) and also produces a row for each Record, although
it does order them by type.

XSL goes something like:

<xsl:key name="options" match="option" use="@type" />
<xsl:key name="oldID" match="Record" use="disabPrimary" />

Change this key to

<xsl:key name="oldID" match="option" use="@oldID" />

<xsl:variable name="$Definitions" select="Document(Disabilities.xml)" />
<xsl:variable name="$Var" select="Document(Records.xml)" />
<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/disabilities">
                                <xsl:value-of select="count(key('oldID',$current))" />

and then change this for-each to:

<xsl:for-each select="$Definitions">
 <xsl:value-of select="count(key('oldID',$current))" />

You have a few other typo's to fix (if you code matches your example)
but that should be it.


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.