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

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

Thanks in advance

Edited by Reverend Jim: Moved to XML, XSLT and XPATH forum

2 Years
Discussion Span
Last Post by george08.08
Featured Replies
  • look here [example 2](http://www.dpawson.co.uk/xsl/sect2/N2018.html) Read More

  • unter xpath function bool operation [xpath function](http://www.w3schools.com/xpath/xpath_functions.asp) [boolean](http://www.w3schools.com/xpath/xpath_functions.asp#boolean) Helmut Hagemann Read More


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


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.

This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.