Is it possible to count the instances of a for-each boolean statement. for example, say you have patients in a hospital and certain criteria must be met to discharge them. 100(%0) health would equal a discharge, pseudo code would read something like this:

totalHealth - HighTemperature + medication * recoveryPeriod

could you then have a choose statement to count the number of patients discharged or still in hospital? eg

<xsl:choose>
<xsl:when test="(totalHealth - HighTemperature + medication * recoveryPeriod) &gt; = 90">
Discharged Patients - <xsl:value-of select="count(true)"/>
</xsl:when>
<xsl:otherwise>
Current Patients - <xsl:value-of select="count(false)"/>
</xsl:otherwise>
<xsl:choose>

I know this code is incorrect, I just want to know if it is possible.

Thanks in advance

show me the xml data
where is tag true

think it is possible

I actually don't have any code to go with this question. It is just something I was wondering if you could do. I know you can count nodes, but I was just curious if you could count the number of times a boolean condition returned true or false.

Thank you, I have looked through this already and could not find the answer, although it won't hurt to view it again. I was wondering if you could do something like this
Discharged: <xsl:value-of select="count(patients[boolean_exp = 'true'])"/> and because my brain is now on a tangent, can you wrap the boolean exression in a variable? So Discharged: <xsl:value-of select="count(patients[$boolean_exp = 'true'])"/>

Thanks Helmut, so much reading to do, so little time. It looks like I would be better off using a recursive template to count the instances. At least I now know it can be done. Thanks

can you show me the xml file
then I can help you, the nodes to count

can you show me the xml file
then I can help you, the nodes to count

Hi Helmut. I don't have any code to accompany this, it was just a generic question to see if it was possible to count instances of boolean returns. The links have have posted indicate it is, so thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.