Project

Profile

Help

Bug #3635

closed

passing stylesheet parameters via fn:transform causes an exception

Added by Liam Quin about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2018-01-21
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:
Platforms:

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

exception-two.xsl (351 Bytes) exception-two.xsl called from exception.xsl Liam Quin, 2018-01-21 02:22
exception.xsl (467 Bytes) exception.xsl main stylesheet Liam Quin, 2018-01-21 02:22
Actions #1

Updated by Martin Honnen about 6 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.

Actions #2

Updated by Michael Kay about 6 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.

Actions #3

Updated by Michael Kay about 6 years ago

Test case added to QT3: fn-transform-err-18

Actions #4

Updated by Liam Quin about 6 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:

Actions #5

Updated by O'Neil Delpratt about 6 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

Also available in: Atom PDF