Thanks alot for your comments and advice.
With this particular problem I don't really have time to learn and use Saxon or Xalan as they seem an education in themselves, as most powerful tools do.
Once I get this issue of performing comparisions on number variables I can finish the task in hand and revist Saxon/Xalan another time when I have more time to do this. (i know this is not ideal, but I have little choice in the matter as I need to get this resolved very quickly).
I think there is an issue with casting the variables as numbers as I have tried setting the variables again like so:
Code:
<xsl:variable name="Price1">
<xsl:choose>
<xsl:when test="Provider='A' and Naming='Pounds'">
<xsl:value-of select='format-number($amount * Rate, "#.000")'/>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Price2">
<xsl:choose>
<xsl:when test="Provider='B' and Naming='Pounds'">
<xsl:value-of select='format-number($amount * Rate, "#.000")'/>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Instead of performing the > comparison I tried this:
Code:
<xsl:value-of select='format-number($Price1 * $Price2, "#.000")'/>
I get 'NaN'. Oddly, if I do either of these things:
1.
Code:
<xsl:value-of select='format-number($Price1 * 2, "#.000")'/>
2.
Code:
<xsl:value-of select='format-number($Price2 * 2, "#.000")'/>
I get a number. It is only when I try to multiply them by each other the issue starts.
Any ideas what could be causing this? I am a total xslt noob as you may have guessed. I am trying to approach this as I would PHP or ASP in this way:
Code:
if ($Price1 > $Price2){
do this
}else{
do the other
}
But by doing this in xslt:
Code:
<xsl:choose>
<xsl:when test="$Price1 > $Price2">
do this
</xsl:when>
<xsl:otherwise>
do the other
</xsl:otherwise>
</xsl:choose>
Can anyone offer some advice on what maybe going wrong? My hunch is that the variables are losing their casting when compared against each for some reason. Do I need to enforce this casting again somehow?
Many thanks!