Bug #4146
closedError not caught by try catch, because an expression is loop-lifted outside the xsl:try
100%
Description
Reported by Mukul Gandhi on xsl:list. Given this stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:err="http://www.w3.org/2005/xqt-errors"
exclude-result-prefixes="err"
version="3.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:try>
<xsl:value-of select="for $x in (1 to count(test/hello)) return (1 div 0)"/>
<xsl:catch errors="*">
<error code="{$err:code}" description="{$err:description}" location="line:{$err:line-number}, col:{$err:column-number}"/>
</xsl:catch>
</xsl:try>
</xsl:template>
</xsl:stylesheet>
Saxon isn't catching the division-by-zero error. The error is reported dynamically, rather than statically, but it occurs outside the scope of the try/catch, apparently as a result of a loop-lifting optimisation.
Updated by Michael Kay about 5 years ago
As far as I can see the LoopLifter class is making no attempt to avoid lifting an expression out of a try/catch.
The simplest fix for this would seem to be to change the logic of LoopLifter.getContainingConditional()
, which is used to prevent loop-lifting outside an xsl:if
or xsl:choose
; this could easily check for an xsl:try
at the same time, and apply exactly the same logic.
Updated by Michael Kay about 5 years ago
- Status changed from New to Resolved
- Applies to branch 9.9, trunk added
- Fix Committed on Branch 9.9, trunk added
Fixed as suggested; test case try-035 added.
Updated by O'Neil Delpratt about 5 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.9.1.2 added
Bug issue fixed in the Saxon 9.9.1.2 maintenance release.
Please register to edit this issue