Bug #2244
closedNo location information available when xsl:import fails
100%
Description
When an xsl:import or xsl:include fails (for example because the referenced file does not exist), the exception that is thrown (or notified to the ErrorListener) contains no location information.
JUnit test case s9apitest/testXsltCompiler/testErrorNotificationFromImportError created to demonstrate the problem
Updated by Michael Kay about 10 years ago
It's clear why this is happening, less clear how to fix it.
In 9.6, in order to make static variables and shadow attributes work properly, xsl:import and xsl:include directives are now processed (expanded) during the SAX building of the containing module, rather than on completion of this process as before. The routine that is called, loadStylesheetModule, is the same as is used for the top-level module. If the XML parser throws an error processing the included module, loadStylesheet module catches the exception and calls the error listener. But loadStylesheetModule does not know the current location in the module from which it was invoked, so this exception has no location information. If instead of being immediately reported, the exception were thrown back to the caller (the UseWhenFilter), the caller would have a chance to add location information before reporting the error. Making this change, however, could conflict with other users of loadStylesheetModule().
Updated by Michael Kay about 10 years ago
The following changes fix the problem and seem safe enough:
(a) In StylesheetModule.loadStylesheetModule(), when an exception is caught, only report it (via Compilation.reportError()) if topLevelModule is true.
(b) In UseWhenFilter, if an exception is caught on return from StylesheetModule.loadStylesheetModule, then as well as adding the location information as now, report the error via Compilation.reportError().
Fix applied on the 9.6 and 9.7 branches.
Updated by Michael Kay about 10 years ago
- Status changed from In Progress to Resolved
Updated by O'Neil Delpratt about 10 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.6.0.3
Bug fix patch applied to the Saxon 9.6.0.3 maintenance release
Updated by O'Neil Delpratt about 9 years ago
- Sprint/Milestone set to 9.6.0.3
- Applies to branch 9.6 added
- Fix Committed on Branch 9.6 added
- Fixed in Maintenance Release 9.6.0.3 added
Please register to edit this issue