XSL problem with numbers bigger than 100000
Posted: Thu May 24, 2012 12:43 pm
Hi,
I have a list of ranges to validate for overlap. E.g.:
Put together from a date range function I have the following XSL function to validate for overlap:
The functions seems to work fine if I run it on the data shown above. If I uncomment (1) it correctly tells that the ranges are overlapping. However whenever I have a range with number above 100000 the function return overlap even though that's not the case.
I'm wondering if I'm doing something wrong in the code or there's a bug in OxygenXML editor? (version 13.2)
Thanks in advance,
Bo
I have a list of ranges to validate for overlap. E.g.:
Code: Select all
<intervals>
<range start="10000" end="15000"/>
<range start="20000" end="25000"/>
<range start="80000" end="85000"/>
<range start="90000" end="95000"/>
<!-- (1) <range start="90000" end="95000"/> -->
<!-- (2) <range start="100000" end="105000"/> -->
</intervals>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:fct="http://custom"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="intervals">
<xsl:choose>
<xsl:when test="fct:check_overlap((),range)">No overlap</xsl:when>
<xsl:otherwise>Overlap!!</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:function name="fct:check_overlap" as="xs:boolean">
<xsl:param name="current_end" as="xs:integer?"/>
<xsl:param name="ranges" as="node()*"/>
<xsl:choose>
<xsl:when test="not(exists($current_end))">
<xsl:variable name="orderedRanges" as="node()*">
<xsl:for-each select="$ranges">
<xsl:sort select="@start"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="fct:check_overlap(
xs:integer($orderedRanges[position()=1]/@end),
$orderedRanges[position()>1])"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="
if (not(exists($ranges))) then true() else
if ($current_end > $ranges[position()=1]/@start) then false() else
fct:check_overlap(
xs:integer($ranges[position()=1]/@end),
$ranges[position()>1])
"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
</xsl:stylesheet>
I'm wondering if I'm doing something wrong in the code or there's a bug in OxygenXML editor? (version 13.2)
Thanks in advance,
Bo