I have 8 main categories. Each category has their own scores from 0-100. I need to display 5 different texts based on the percentage range of that score.
For example: Category 1 - score is 46% Show these texts when the score is between these ranges: Text 1: 0-40% Text 2: 41-60% Text 3: 61-80% Text 4: 81-90% Text 5: 91-100%
In this case, I need to display "Text 2" because 46% falls into that range.
How could I do that?
I have tried to write a code for this, but I'm not sure how to specify the percentage ranges in the template section.
XSL-FO document:
<xsl:call-template name="information">
<xsl:with-param name="score" select="//attribute-lines[*/id = 'Path-Brick-Attribute']/*/value-text"/>
</xsl:call-template>
Template section in the XSL document:
`<xsl:template name="information">
<xsl:param name="score"/>
<xsl:choose>
<xsl:when test="$score >= 0 and 40 >=">
<fo:block>
<xsl:text>
Text 1
</xsl:text>
</fo:block>
</xsl:when>
<xsl:when test="$score >= 41 and >= 60">
<fo:block>
<xsl:text>
Text 2
</xsl:text>
</fo:block>
</xsl:when>
</xsl:choose>
</xsl:template>`
The pattern you need to use is:
This works because
xsl:choose
exits at the first test that returns true.Note that this requires
$score
to be given as a number (0..100), not as a percentage.