Bug #3635
closedpassing stylesheet parameters via fn:transform causes an exception
100%
Description
If i run the enclosed stylesheet, i get an error; this is a stripped-down example. I get what looks like the same error if i try to pass an option map to fn:serialize. In both cases i can work round it by passing an XML fragment.
I also get the same (or a similr, didn't check) error with Saxon EE run from Oxygen XML Editor version 19 (didn't try earlier versions).
java -jar /home/lee/packages/saxonpe/saxon9pe.jar exception.xsl exception.xsl
java.lang.RuntimeException: Internal error evaluating template rule at line 7 in module file:/home/lee/mulberry/balisage-proceedings/deliver/exception.xsl
at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:360)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:502)
at net.sf.saxon.Controller.transformDocument(Controller.java:2402)
at net.sf.saxon.Controller.transform(Controller.java:1970)
at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:593)
at net.sf.saxon.Transform.processFile(Transform.java:1257)
at net.sf.saxon.Transform.doTransform(Transform.java:780)
at net.sf.saxon.Transform.main(Transform.java:81)
Caused by: java.lang.ClassCastException: net.sf.saxon.value.StringValue cannot be cast to net.sf.saxon.value.QNameValue
at net.sf.saxon.functions.TransformFn.call(TransformFn.java:639)
at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:547)
at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:434)
at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:347)
... 7 more
Fatal error during transformation: java.lang.RuntimeException: Internal error evaluating template rule at line 7 in module file:/home/lee/mulberry/balisage-proceedings/deliver/exception.xsl
Files
Updated by Martin Honnen almost 7 years ago
I think you have three problems in your use of transform@, the first is that you need to use a @QName
(and not a string) for the parameter name, the second is that the transform
function returns a map where you find the primary result as the map item named output
and the third is that you use xsl:copy
(which only makes a shallow copy) instead of xsl:copy-of
(which creates a deep copy) when you try to output the result of the function. So what you want is
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/">
<xsl:copy-of
select="
transform(
map {
'stylesheet-location': 'test201801210102.xsl',
'source-node': /,
'stylesheet-params': map {
QName('', 'garment'): 'hoodie',
QName('', 'colour'): 'black'
}
}
)?output"
/>
</xsl:template>
</xsl:stylesheet>
I think.
Updated by Michael Kay almost 7 years ago
- Category set to Diagnostics
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Applies to branch trunk added
- Fix Committed on Branch 9.8, trunk added
The exception occurs because the parameter name is supplied as a string rather than a QName, and Saxon is failing to check for this error.
The same happens with other similar options, e.g. template-params and tunnel-params.
I have added code to check this condition and report FOXT0002.
Updated by Michael Kay almost 7 years ago
Test case added to QT3: fn-transform-err-18
Updated by Liam Quin almost 7 years ago
You are right on all three counts, sorry for the noise!
The F&O spec does say Type: map(xs:QName, item()*) for stylesheet-
params.
On the other hand, it'd be helpful not to have Saxon crash...
On Sun, 2018-01-21 at 15:39 +0100, Saxonica Developer Community wrote:
Updated by O'Neil Delpratt almost 7 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.8.0.8 added
Bug fix applied in the Saxon 9.8.0.8 maintenance release.
Please register to edit this issue