Strange Behavior when Comapring xs:decimal type in Schematron
Posted: Fri Jan 31, 2020 10:58 pm
I have the following in an XML Schema:
I have written a Schematron function:
The first assertion is simply so that the values get printed out as a sanity check. What prints out is as follows (the Conditioned value seems to be getting read in correctly):
As you see, the value comparison check doesn't fire.
However, if I change the second assertion to check if it is LESS THAN, i.e.
the rule fires:
The other thing is that, it WILL FIRE correctly with certain values. For example:
and I change the rule back to the original (i.e. it is checking to make sure that the Gross Area >= Conditioned Area), it fires correctly:
Why would this be happening? It seems so outrageously inconsistent.
For reference:
The datatype of the auc:FloorAreaValue is an extension of 'xs:decimal'
I am running XML Editor 21.1, build 2019071807 on macOS 10.14.6
Code: Select all
<auc:FloorAreas>
<auc:FloorArea>
<auc:FloorAreaType>Gross</auc:FloorAreaType>
<auc:FloorAreaValue>24695</auc:FloorAreaValue>
</auc:FloorArea>
<auc:FloorArea>
<auc:FloorAreaType>Conditioned</auc:FloorAreaType>
<auc:FloorAreaValue>124411</auc:FloorAreaValue>
</auc:FloorArea>
<auc:FloorArea>
<auc:FloorAreaType>Cooled only</auc:FloorAreaType>
<auc:FloorAreaValue>234</auc:FloorAreaValue>
</auc:FloorArea>
</auc:FloorAreas>
Code: Select all
<!--
Check that the GrosConditioned area is greater than Cooled only + Heated only + Heated and Cooled + Ventilated
<severity> error
<param> parent - an auc:FloorArea[auc:FloorAreaType='Conditioned' and auc:FloorAreaValue] element
-->
<pattern abstract="true" id="fa.conditionedValueChecks">
<rule context="$faNode">
<let name="grossArea" value="if (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Gross']) then (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Gross']/parent::auc:FloorArea/auc:FloorAreaValue) else (0.0)"/>
<let name="cooledOnlyArea" value="if (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Cooled only']) then (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Cooled only']/parent::auc:FloorArea/auc:FloorAreaValue) else (0.0)"/>
<let name="heatedOnlyArea" value="if (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Heated only']) then (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Heated only']/parent::auc:FloorArea/auc:FloorAreaValue) else (0.0)"/>
<let name="heatedCooledArea" value="if (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Heated and Cooled']) then (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Heated and Cooled']/parent::auc:FloorArea/auc:FloorAreaValue) else (0.0)"/>
<let name="ventilatedArea" value="if (parent::node()/auc:FloorArea/auc:FloorAreaType[text()='Ventilated']) then (auc:FloorArea/auc:FloorAreaType[text()='Ventilated']/parent::auc:FloorArea/auc:FloorAreaValue) else (0.0)"/>
<let name="conditionedAreaValue" value="auc:FloorAreaValue/text()"/>
<assert test="false()">
JUST PRINT VALUES: Gross Area (<value-of select="$grossArea"/>) must be greater than or equal to Conditioned Area Value (<value-of select="$conditionedAreaValue"/>)
</assert>
<assert test="$grossArea >= $conditionedAreaValue">
Gross Area (<value-of select="$grossArea"/>) must be greater than or equal to Conditioned Area Value (<value-of select="$conditionedAreaValue"/>)
</assert>
<assert test="$conditionedAreaValue >= $cooledOnlyArea + $heatedOnlyArea + $heatedCooledArea + $ventilatedArea">
Conditioned Area Value (<value-of select="$conditionedAreaValue"/>) must be greater than or equal to: Heated and Cooled (<value-of select="$heatedCooledArea"/>) + Heated only (<value-of select="$heatedOnlyArea"/>) + Cooled only (<value-of select="$cooledOnlyArea"/>) + Ventilated (<value-of select="$ventilatedArea"/>)
</assert>
</rule>
</pattern>
However, if I change the second assertion to check if it is LESS THAN, i.e.
Code: Select all
<assert test="$grossArea <= $conditionedAreaValue">
Gross Area (<value-of select="$grossArea"/>) must be greater than or equal to Conditioned Area Value (<value-of select="$conditionedAreaValue"/>)
</assert>
Code: Select all
<auc:FloorAreas>
<auc:FloorArea>
<auc:FloorAreaType>Gross</auc:FloorAreaType>
<auc:FloorAreaValue>24695</auc:FloorAreaValue>
</auc:FloorArea>
<auc:FloorArea>
<auc:FloorAreaType>Conditioned</auc:FloorAreaType>
<auc:FloorAreaValue>24696</auc:FloorAreaValue>
</auc:FloorArea>
<auc:FloorArea>
<auc:FloorAreaType>Cooled only</auc:FloorAreaType>
<auc:FloorAreaValue>234</auc:FloorAreaValue>
</auc:FloorArea>
</auc:FloorAreas>
For reference:
The datatype of the auc:FloorAreaValue is an extension of 'xs:decimal'
I am running XML Editor 21.1, build 2019071807 on macOS 10.14.6