Project

Profile

Help

Bug #6305

closed

XPathException "The stylesheet module includes/imports itself directly or indirectly" has no locator

Added by Gerben Abbink 4 months ago. Updated 3 days ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2023-12-22
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

I use an ErrorReporter with XsltCompiler, like this:

XsltCompiler compiler = processor.newXsltCompiler();
compiler.setErrorReporter(...);

Usually, XPathExceptions have a Location to identify the error in the file.

But, when I use this template, there is no location information:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:import href=""/>
</xsl:stylesheet>
Actions #1

Updated by Gerben Abbink 4 months ago

I have the same problem when the href attribute has a value, but the file does not exist:

<xsl:import href="DOES-NOT-EXIST"/>

Actions #2

Updated by Gerben Abbink 4 months ago

I tested all the files in the XSLT 3.0 Test Suite and found that these errors have no location information

err:XTDE0030 = The lang attribute must be a valid language code .../tests/insn/number/number-0825.xsl

err:XTSE0180 = The stylesheet module includes/imports itself directly or indirectly .../tests/misc/error/error-0180a.xsl

err:XTSE0545 = For mode c, there are conflicting values for xsl:mode/@on-no-match at the same import precedence .../tests/attr/mode/mode-1502.xsl

err:XTSE1290 = Inconsistency in decimal format d. There are two inconsistent values for decimal-format property percent at the same import precedence .../tests/misc/error/error-1290b.xsl

err:XTSE3080 = The package is not executable, because it contains abstract components: function p:f-abstract#2 << WHY #2?? .../tests/decl/override/override-base-f-001.xsl

err:SESU0013 = Unsupported HTML version. file:///C:/XMLBP%20Test%20Files/XML%20Conformance%20Tests/XSLT-testsuite-04/testsuite/TESTS/MSFT_Conformance_Tests/Output/84306.xsl

err:SESU0013 = XML version must be 1.0 or 1.1 url=file:///C:/XMLBP%20Test%20Files/XML%20Conformance%20Tests/XSLT-testsuite-04/testsuite/TESTS/MSFT_Conformance_Tests/Output/xslt29107.xsl

err:SXXP0003 = I/O error reported by XML parser processing file:///C:/XMLBP%20Test%20Files/XML%20Conformance%20Tests/XSLT-testsuite-04/testsuite/TESTS/MSFT_Conformance_Tests/ProcessingInstruction/XSLT16001.xsl file:///C:/XMLBP%20Test%20Files/XML%20Conformance%20Tests/XSLT-testsuite-04/testsuite/TESTS/MSFT_Conformance_Tests/ProcessingInstruction/XSLT16001.xsl

Actions #3

Updated by Michael Kay 4 months ago

Thanks for this list, I'll go through it to see what improvements we can make. In most cases if there's no location information it's either because the error isn't obviously associated with one particular location (e.g. XTSE0545) (though if there are inconsistencies between constructs different locations we generally try to report at least one of them), or because the location isn't conveniently available at the point where we detect the error. But in other cases it may be an oversight, and there's always room for improvement.

Actions #4

Updated by Michael Kay 4 months ago

Fixed the xsl:import/include case - the location was being set in the exception AFTER reporting it to the error listener.

Fixed number-0825,

mode-1502 - this is more difficult because it's a consistency check across multiple declarations; a mode may be declared in multiple places (or in none) so it doesn't have a simple location.

error-1290b - similar problem. We do the consistency check at the end, at a point where we don't know where the data we are checking came from.

XTSE3080 - not quite sure which test is failing here. Outputting a location is complicated because we output a list of the names of all offending abstract components, but it's easy enough to change it to output the location of the first.

Last 3 tests (serialization errors) I'm not familiar with the "MSFT_Conformance_Tests" test suite being run here. In general, it may be difficult to relate serialization errors to a location in the stylesheet.

The problem with the version parameters is that in the general case, we don't know what serialization method we are using until the first start tag is written to the result tree, and at that point we don't know what xsl:output or xsl:result-document element (or external serialization parameter) caused a particular HTML or XML version to be requested.

Actions #5

Updated by Michael Kay 3 days ago

  • Category set to Diagnostics
  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Applies to branch 12, trunk added
  • Fix Committed on Branch 12, trunk added
  • Platforms .NET, Java added

I have made progress ensuring that as many errors as possible hae location information; I'm now going to close this as resolved.

Please register to edit this issue

Also available in: Atom PDF