[thelist] xsl count (these only)
Juha Katila
wallpasser at gmail.com
Mon Jun 5 06:41:33 CDT 2006
Hello!
I've tried to solve some a problem I've had now for some time but
nothing seems to work. Could anybody here help me?
I have questionnaire results in xml about different courses held at
the same time.
The format is something like this:
<feedback>
<answer>
<basicinfo>
<courseid>foodcourse</courseid>
</basicinfo>
<arquements>
<q1>a2</q1> <<<--- answers can have value a1,a2,a3 or a4
<q2>a1</a2>
<q3>a2</q3>
</arquements>
</answer>
<answer>
<basicinfo>
<courseid>foodcourse</courseid>
</basicinfo>
<arquements>
<q1>a2</q1> <<<--- answers can have value a1,a2,a3 or a4
<q2>a2</a2>
<q3>a4</q3>
</arquements>
</answer>
<answer>
<basicinfo>
<courseid>mathcourse</courseid>
</basicinfo>
<arquements>
<q1>a4</q1> <<<--- answers can have value a1,a2,a3 or a4
<q2>a3</a2>
<q3>a1</q3>
</arquements>
</answer>
<answer>....and so on</answer>
<answer>....and so on</answer>
</feedback>
Now the problem is that I should need counting results in xsl how many
(of those who were only i.e. at the foodcourse) answered to the q1
with the value "a2".
I can get all the results in the file summed together i.e. for q1 with:
<xsl:for-each select="feedback">
<xsl:value-of select="count(answer/arquements[q1 = 'a1'])"/>
<xsl:value-of select="count(answer/arquements[q1 = 'a2'])"/>
<xsl:value-of select="count(answer/arquements[q1 = 'a3'])"/>
<xsl:value-of select="count(answer/arquements[q1 = 'a4'])"/>
</xsl:for-each>
But how in the world I get only the summed results for a selected
course like this
<xsl:for-each select="feedback">
<xsl:value-of select="count [[[[[[ ONLY THE ANSWERS WHERE
basicinfo/courseid IS 'foodcourse' ]]]]] (answer/arquements[q1 =
'a1'])"/>
<xsl:value-of select="count [[[[[[ ONLY THE ANSWERS WHERE
basicinfo/courseid IS 'foodcourse' ]]]]] (answer/arquements[q1 =
'a2'])"/>
<xsl:value-of select="count [[[[[[ ONLY THE ANSWERS WHERE
basicinfo/courseid IS 'foodcourse' ]]]]] (answer/arquements[q1 =
'a3'])"/>
<xsl:value-of select="count [[[[[[ ONLY THE ANSWERS WHERE
basicinfo/courseid IS 'foodcourse' ]]]]] (answer/arquements[q1 =
'a4'])"/>
</xsl:for-each>
I've tried xsl:if and others but any of them doesn't work the way I want to.. :(
Help would be sooo appreciated!
Thanks!
-juha-
More information about the thelist
mailing list