I have a bunch of costs in my XML that I am trying to compare against another cost value, to determine which values to display (only ones higher than the comparator). This works when the numbers use the decimal point as the separator but not with numbers using comma as the decimal separator. I could be getting either, depending on the locale.
Here's what I have:
<patron_max_cost><![CDATA[1,00]]></patron_max_cost>
<service_costs>
<location_cost>
<location_desc><![CDATA[location1]]></location_desc>
<cost_to_user><![CDATA[0,99]]></cost_to_user>
</location_cost>
<location_cost>
<location_desc><![CDATA[location2]]></location_desc>
<cost_to_user><![CDATA[1,50]]></cost_to_user>
</location_cost>
</service_costs>
<xsl:variable name="filtered_location_costs">
<xsl:for-each select="service_costs/location_cost">
<xsl:if test="number(cost_to_user) > number(patron_max_cost)">
<xsl:copy-of select="." />
</xsl:if>
</xsl:for-each>
</xsl:variable>
This fails because cost_to_user and patron_max_cost are NaN. Is there a way of doing this comparison that will work for both input styles and doesn't involve something kludgy like converting the commas to decimal points before comparing? I am using XSLT2.0 and Saxon8.