How to enable XSLT 4 syntax extension with SaxonCS EE?
Added by Martin Honnen about 3 years ago
I wanted to experiment with the XSLT 4 / XPath 4 syntax extension with SaxonCS EE 11 but I can't get it to work, example file is
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="4.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:output method="text"/>
<xsl:template match="/" name="xsl:initial-template">
<xsl:for-each select="random-number-generator()?permute(1 to 10)" separator=", ">{.}</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Example command line under Windows 10: 'C:\Program Files\Saxonica\SaxonCS-11.0\SaxonCS.exe' transform -t -it -xsl:.\for-each-separator-test1.xsl --allowSyntaxExtensions:on
Result:
SaxonCS-EE 11.0 from Saxonica
.NET 5.0.9 on Windows 10.0.19043.0
Using license serial number V.....
Error in xsl:for-each/@separator on line 11 column 6 of for-each-separator-test1.xsl:
XTSE0020 Attribute xsl:for-each/@separator is allowed only if XSLT 4.0 is enabled
Errors were reported during stylesheet compilation
Exiting with code 2
The documentation https://www.saxonica.com/html/documentation11/v4extensions/ says: "equivalently, use --allowSyntaxExtensions:on on the command line".
Thus, it seems I have tried what the documentation suggests. What am I missing?
Replies (3)
Please register to reply
RE: How to enable XSLT 4 syntax extension with SaxonCS EE? - Added by Martin Honnen about 3 years ago
I am still not able to get XSLT 4 syntax extensions to run, even now providing an configuration file (which only seems to work with a absolute file path), but Saxon stubbornly tells me "XTSE0020 Attribute xsl:for-each/@separator is allowed only if XSLT 4.0 is enabled".
PS C:\Users\marti\OneDrive\Documents\xslt\xslt4-examples> & 'C:\Program Files\Saxonica\SaxonCS-11.0\SaxonCS.exe' transform -t -it -xsl:separator-examples\for-each-separator-test1.xsl -config:C:\Users\marti\OneDrive\Documents\xslt\xslt4-examples\saxoneexslt4XPath4syntaxextensions-config.xml
.NET 5.0.9 on Windows 10.0.19043.0
Using license serial number V....
Error in xsl:for-each/@separator on line 11 column 6 of for-each-separator-test1.xsl:
XTSE0020 Attribute xsl:for-each/@separator is allowed only if XSLT 4.0 is enabled
Errors were reported during stylesheet compilation
Exiting with code 2
Meanwhile, while the Saxon 10 documentation doesn't mention any support for the separator
attribute, I can run the example suprisingly fine through Saxon EE 10.6 Java.
Should extensions work with SaxonCS EE as currently released?
RE: How to enable XSLT 4 syntax extension with SaxonCS EE? - Added by Michael Kay about 3 years ago
It should work, but you're running up against the fact that 99% of our testing is done using the C# API rather than the command line, so there may be usability glitches on the command line that we've overlooked.
I'll look into it to see whether I can find workarounds for these issues.
RE: How to enable XSLT 4 syntax extension with SaxonCS EE? - Added by Martin Honnen about 3 years ago
I run my XSLT "4" now through C# using e.g.
var processor = new Processor();
var xsltCompiler = processor.NewXsltCompiler();
xsltCompiler.XsltLanguageVersion = "4.0";
var xsltExecutable = xsltCompiler.Compile(new Uri(@"C:\Users\marti\OneDrive\Documents\xslt\xslt4-examples\separator-examples\for-each-separator-test2.xsl"));
and then indeed the code works as intended.
So somehow the command line interface is not yet up to the task to enable the syntax extensions, at least not the ways I have tried.
Please register to reply