Reputation: 23
We installed and ran XSpec and configured it to point to our stylesheet resulting in an error:
[ERROR] Cannot execute xsl:result-document while evaluating xsl:variable; SystemID: file:/Users/a/xspec/ce.xslt; Line#: 76; Column#: 114 net.sf.saxon.trans.XPathException: Cannot execute xsl:result-document while evaluating xsl:variable
A similar error has been found by user:wasmachien and a question was raised on xsl:result-document instruction throws error when invoking stylesheet with Calabash
The solution to the error was not given, but it pointed to:
the error was thrown by the XSpec test runner that preceded the transformation step in the pipeline (and tried to wrap the result in a variable!)
We would be helped if we know how to avoid that behaviour.
Upvotes: 1
Views: 449
Reputation: 61
As answered by the others, that is an inherent limitation of the current XSpec implementation. You have to tweak your stylesheet to make it testable.
"High-Level File Structure to Enable Substitution" and "Case 1: Creating Result Documents" in galtm's paper might give you some hint. It's based on Saxon-JS, but many of its strategies are applicable to Saxon Java.
Upvotes: 0
Reputation: 1036
Ultimately, the problem here is that XSpec attempts to capture the output of the transformation in a variable so that it can compare the results against what's expected. But you can't have an xsl:result-document
in a variable for the reasons Mike describes.
Without an XSpec rewrite to avoid this, you have to twist your stylesheet so that it doesn't attempt to use xsl:result-document
within the templates that are being tested (or when they're being tested).
There's some magic along these lines in the tests for https://github.com/docbook/xslTNG/
Upvotes: 0
Reputation: 163262
XSLT is a functional language, so evaluating a variable isn't supposed to have side-effects like creating an output file. The error message means that you're trying to cause such a side-effect. This would be bad news because side-effects prevent many optimisations, so the XSLT spec bans this.
Of course I can see why this is a nuisance. If you have some code that's doing a transformation then you want to be able to capture the result of the code in a variable. But the whole point is that if the code has side-effects, then you can't encapsulate it in this way: in effect, the code is actually producing multiple results.
I don't know whether anyone has worked on making XSpec able to run XSLT transformations using fn:transform()
. That would be an ideal solution, because fn:transform
allows the target transformation to produce multiple results using xsl:result-document
, and it captures all the result documents using a map.
Upvotes: 1