Bug #5038
closedGetting error XTTE0590 'Required cardinality of value of parameter $stylesheet-base-uri is exactly one; supplied value is empty' when calling fn:transform with stylesheet-node created from fn:parse-xml
100%
Description
Under Node.js, when running the code
const SaxonJS = require('saxon-js');
const xslt1Source = `<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="data">
<h1><xsl:value-of select="name" /></h1>
<div>Age: <xsl:value-of select="age" /></div>
</xsl:template>
</xsl:stylesheet>`;
const xmlSource = `<data>
<name>John</name>
<age>25</age>
</data>`;
const result = SaxonJS.XPath.evaluate(`
transform(
map {
'source-node' : parse-xml($xmlSource),
'stylesheet-node' : parse-xml($xsltSource)
}
)?output`,
[],
{ 'params' : { 'xmlSource' : xmlSource, 'xsltSource' : xslt1Source } }
);
console.log(result);
I get the error
message: 'Required cardinality of value of parameter $stylesheet-base-uri is exactly one; supplied value is empty',
name: 'XError',
code: 'XTTE0590',
xsltLineNr: '408',
xsltModule: 'XSLT-SEF-compiler.xsl'
https://www.w3.org/TR/xpath-functions/#func-transform says about stylesheet-base-uri
: "A string intended to be used as the static base URI of the principal stylesheet module. This value must be used if no other static base URI is available. If the supplied stylesheet already has a base URI (which will generally be the case if the stylesheet is supplied using stylesheet-node or stylesheet-location) then it is ·implementation-defined· whether this parameter has any effect.".
I think setting a value for stylesheet-base-uri
is not mandatory if a node is supplied as stylesheet-node
.
Using 'stylesheet-text' : $xsltSource
instead of 'stylesheet-node' : parse-xml($xsltSource)
works fine so in that case Saxon-JS somehow has a base URI for the stylesheet or takes a different path not caring about the base URI.
A similar XQuery code run with Saxon-Java works fine without setting up the stylesheet-base-uri
:
let $xml-source := ``[<data>
<name>John</name>
<age>25</age>
</data>]``,
$xslt-source := ``[<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="data">
<h1><xsl:value-of select="name" /></h1>
<div>Age: <xsl:value-of select="age" /></div>
</xsl:template>
</xsl:stylesheet>]``
return
transform(
map {
'source-node' : parse-xml($xml-source),
'stylesheet-node' : parse-xml($xslt-source)
}
)?output
so that seems to support my understanding that Saxon-JS has a bug here when raising the error about the stylesheet-base-uri
.
Please register to edit this issue
Also available in: Atom PDF Tracking page