Strange Behavior when Comapring xs:decimal type in Schematron
Oxygen general issues.
-
- Posts: 6
- Joined: Tue Jan 28, 2020 2:05 am
Strange Behavior when Comapring xs:decimal type in Schematron
Post by corymosiman12 »
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):
However, if I change the second assertion to check if it is LESS THAN, i.e.
the rule fires:
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:
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>
Screen Shot 2020-01-31 at 12.46.59 PM.png
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.
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>
Screen Shot 2020-01-31 at 12.50.38 PM.png
The other thing is that, it WILL FIRE correctly with certain values. For example:
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>
Screen Shot 2020-01-31 at 12.55.07 PM.png
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
You do not have the required permissions to view the files attached to this post.
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Strange Behavior when Comapring xs:decimal type in Schematron
Hello,
I think that the problem is that you compare the string values of the numbers. You need to convert the text value into a number using the number() function. The condition must be something like this "number($grossArea) >= $conditionedAreaValue".
Best Regards.
Octavian
I think that the problem is that you compare the string values of the numbers. You need to convert the text value into a number using the number() function. The condition must be something like this "number($grossArea) >= $conditionedAreaValue".
Best Regards.
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 6
- Joined: Tue Jan 28, 2020 2:05 am
Re: Strange Behavior when Comapring xs:decimal type in Schematron
Post by corymosiman12 »
Yes that was simple...thank you!
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service