Support #6280
closedxsl:apply-templates without select attribute not working properly in xsl:template with multiple modes
0%
Description
When testing Saxon-EE 12.4, we got the following error message during one of our transformations (see attachment):
2023-12-04 22:12:49 [INFO] Batch execution starting...
2023-12-04 22:12:49 [DEBUG] Deleting C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/output/
2023-12-04 22:12:49 [DEBUG] Sleeping for 1 seconds...
2023-12-04 22:12:50 [DEBUG] Execution time: 1.026s
2023-12-04 22:12:50 [DEBUG] Creating C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/output/
2023-12-04 22:12:50 [DEBUG] Execution time: 0.005s
2023-12-04 22:12:50 [INFO] Transforming file:/C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/input/graphicalEdge.xml
2023-12-04 22:12:50 [INFO] into file:/C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/output/graphicalEdge.xml
2023-12-04 22:12:50 [INFO] using downgrade.xslt
2023-12-04 22:12:50 [INFO] parameter macro-target-schema-version=4
2023-12-04 22:12:50 [DEBUG] Exporting file:/C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/output/graphicalEdge.xml
2023-12-04 22:12:50 [DEBUG] Execution time: 0.23s
2023-12-04 22:12:50 [INFO] Transforming file:/C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/input/trackEdge.xml
2023-12-04 22:12:50 [INFO] into file:/C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/output/trackEdge.xml
2023-12-04 22:12:50 [INFO] using downgrade.xslt
2023-12-04 22:12:50 [INFO] parameter macro-target-schema-version=4
Type error at xsl:apply-templates on line 228 column 51 of downgrade.xslt:
XTTE0570 The required item type of the value of variable $updated-element is element();
the supplied value text{} does not match. The supplied value is a text node
In template rule with match="element(Q{http://www.infrabel.be/int/macro}trackEdges)" on line 223 of downgrade.xslt
Focus
Context item: /macro:trackEdges
Context position: 1
Local variables
(All variables are null)
invoked by xsl:apply-templates (tail calls omitted) at file:/C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/xslt/downgrade.xslt#21
2023-12-04 22:12:50 [ERROR] description: The required item type of the value of variable $updated-element is element(); the supplied value text{} does not match. The supplied value is a text node
2023-12-04 22:12:50 [ERROR] module: file:/C:/Data/MyProjects/int-batch/src/test/resources/saxon/apply-templates-xxxx/xslt/downgrade.xslt
2023-12-04 22:12:50 [ERROR] line-number: 228
2023-12-04 22:12:50 [ERROR] Batch execution failed - see above output for any hints
Error in xsl:sequence/@select on line 26 column 45 of batch.xslt:
FOER0000 Error signalled by application call on error()
In template xsl:initial-template on line 12 column 56 of batch.xslt:
Focus: absent
Local variables
$vv:v0 {fn:current-date() lt xs:date("2000-01-01")} = false()
$startTime = xs:dateTimeStamp("2023-12-04T22:12:49.135+01:00")
In template xsl:initial-template on line 12 column 56 of batch.xslt:
Focus: absent
Local variables
$vv:v0 {fn:current-date() lt xs:date("2000-01-01")} = false()
$startTime = xs:dateTimeStamp("2023-12-04T22:12:49.135+01:00")
Error signalled by application call on error()
The transformation succeeds for macro:graphicalEdges. This element matches 2 templates each having a single mode. The transformation fails for macro:trackEdges. This element matches 1 template with 2 modes. In any case, the error message is somewhat misleading. Note that the problem was already present in 12.3 and that the problem is fixed when line 228 of downgrade.xslt is changed to
<xsl:apply-templates select="*" mode="#current"/>
Files
Updated by Johan Gheys 12 months ago
- File apply-templates.zip apply-templates.zip added
Added attachment.
Updated by Michael Kay 12 months ago
First observation is that the problem still occurs if we cut out the xsl:perform-sort
and just do the xsl:apply-templates
.
It seems that the tree that we are processing using xsl:apply-templates
includes whitespace-only text nodes; these are being processed using the built-in text-only-copy ruleset, in mode from-5-to-4; this built-in template rule generates the text nodes that cause the type error.
Updated by Michael Kay 12 months ago
It seems to be fairly clear why it is failing: the element macro:trackEdges
contains a sequence of macro:trackEdge
element separated by unstripped whitespace text nodes, and these text nodes are being copied to the output of the apply-templates, which is expecting a sequence of elements and no text nodes.
Why isn't it failing the same way for the processing of graphicalEdges.xml? Because the template rule that would fail, <xsl:template match="macro:graphicalEdges" mode="from-5-to-3">
, isn't executed: it applies only to mode from-5-to-3, which we aren't executing.
Adding <xsl:strip-space elements="*"/>
to downgrade.xslt seems to remove the problem.
I see no evidence of a bug here...
Updated by Johan Gheys 12 months ago
Indeed Michael, you are absolutely right. The transformation is part of a series of transformations and crashes sometimes and sometimes not. I tried to isolate and simplify it and thought (wrongly) I had identified the underlying problem. My apologies and sorry for the time you spent on it.
Updated by Michael Kay 12 months ago
- Tracker changed from Bug to Support
- Status changed from New to Closed
No problem. A non-bug is less work than a bug, so it's a pleasure to find them!
Please register to edit this issue