Logical test in Schematron
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Logical test in Schematron
Post by DanOvergaard »
Hi
I have a task to design a validation using schematron, but I can’t figure if it’s possible.
The validation is a two parts validation as following:
I have the values in the following two variables
Question
How to “code” the logic below in “schematron” – if possible
If ("PayableSum" = -0) then
----Variable "AlteredPayableSum" = 0
Else
----Variable "AlteredPayableSum" = PayableSum
Final validation
Hope somebody can help
Rgds,
Dan
I have a task to design a validation using schematron, but I can’t figure if it’s possible.
The validation is a two parts validation as following:
- First, I need to ensure that variable 1 is converted to 0 if the original value is -0
- Second, I need check if the value in the two variables are the same
I have the values in the following two variables
- Variable 1: <sch:let name="PayableSum" value="format-number (sum(PayableAmount) ,'##.00')"/>
- Variable 2: <sch:let name="TotalSum" value="format-number (sum(TotalAmout) ,'##.00')"/>
Question
How to “code” the logic below in “schematron” – if possible
If ("PayableSum" = -0) then
----Variable "AlteredPayableSum" = 0
Else
----Variable "AlteredPayableSum" = PayableSum
Final validation
- <sch:assert test="$AlteredPayableSum = $TotalSum">The two amounts are not equal</sch:assert>
Hope somebody can help
Rgds,
Dan
Re: Logical test in Schematron
Hello Dan,
Probably you should not format the values before comparing them. A solution to compute the "AlteredPayableSum" is something like this:
Best Regards,
Octavian
Probably you should not format the values before comparing them. A solution to compute the "AlteredPayableSum" is something like this:
Code: Select all
<sch:let name="PayableSum" value="sum(PayableAmount)"/>
<sch:let name="TotalSum" value="sum(TotalAmout)"/>
<sch:let name="AlteredPayableSum" value="if ($PayableSum = -0) then 0 else $PayableSum"/>
<sch:assert test="$AlteredPayableSum = $TotalSum">The two amounts are not equal</sch:assert>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Re: Logical test in Schematron
Post by DanOvergaard »
Hi Octavian,
Thanks for your solution - it seams to work, but after conversion to XLST I get the following syntax error:
Error in expression if ($PayableSum = -0) then 0 else $PayableSum: Unknown system function: if
Is that because the transformation to XSLT enforce XSLT 1.0 ? If so is there a schematron solution for the test that can run XSLT 1.0
Best regards,
Dan
Thanks for your solution - it seams to work, but after conversion to XLST I get the following syntax error:
Error in expression if ($PayableSum = -0) then 0 else $PayableSum: Unknown system function: if
Is that because the transformation to XSLT enforce XSLT 1.0 ? If so is there a schematron solution for the test that can run XSLT 1.0
Best regards,
Dan
Re: Logical test in Schematron
Hello Dan,
You can change the XSLT/XPath version to 2.0 for Schematron by setting the queryBinding="xslt2" on the Schematron root..
If you want to use XSLT 1.0 I think you can change the value of the $AlteredPayableSum variable, something like this:
Best Regards,
Octavian
You can change the XSLT/XPath version to 2.0 for Schematron by setting the queryBinding="xslt2" on the Schematron root..
If you want to use XSLT 1.0 I think you can change the value of the $AlteredPayableSum variable, something like this:
Code: Select all
<sch:let name="AlteredPayableSum">
<xsl:choose>
<xsl:when test="$PayableSum = -0">0</xsl:when>
<xsl:otherwise><xsl:value-of select="$PayableSum"/></xsl:otherwise>
</xsl:choose>
</sch:let>
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Re: Logical test in Schematron
Post by DanOvergaard »
Hi Octavian,
Thanks for your feedback - It gave my the hint to get it to work. I couldn't combined Schematron with XSL but a "clean" XSL variable definition did it
<xsl:variable name="AlteredPayableSum">
<xsl:choose>
<xsl:when test="$PayableSum = -.0">0</xsl:when>
<xsl:otherwise><xsl:value-of select="$PayableSum "/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
Best regards,
Dan
Thanks for your feedback - It gave my the hint to get it to work. I couldn't combined Schematron with XSL but a "clean" XSL variable definition did it
<xsl:variable name="AlteredPayableSum">
<xsl:choose>
<xsl:when test="$PayableSum = -.0">0</xsl:when>
<xsl:otherwise><xsl:value-of select="$PayableSum "/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
Best regards,
Dan
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