Bug #5037
closedempty AVT causes error "Cannot read property 'value' of null"
100%
Description
The spec https://www.w3.org/TR/xslt-30/#value-templates allows AVTs to be empty: "A variable part consists of an optional XPath expression enclosed in curly brackets ({}): more specifically, a string conforming to the XPath production Expr?.", saying that "The fact that the expression is optional means that the string contained between the curly brackets may be zero-length, may comprise whitespace only, or may contain XPath comments. The effective value in this case is a zero-length string, which is equivalent to omitting the variable part entirely, together with its curly-bracket delimiters.".
However, with Saxon-JS 2.2, both in the browser or on Node.js, the code
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/" name="xsl:initial-template">
<test>
<xsl:variable name="element-name" select="'foo'"/>
<xsl:element name="{$element-name}" namespace="{}">test</xsl:element>
</test>
<xsl:comment>Run with <xsl:value-of select="system-property('xsl:product-name')"/>; <xsl:value-of select="system-property('xsl:product-version')"/></xsl:comment>
</xsl:template>
</xsl:stylesheet>
gives an error "Cannot read property 'value' of null".
The code runs fine with Saxon Java, I think Saxon-JS has a bug here.
Please register to edit this issue
Also available in: Atom PDF Tracking page