Project

Profile

Help

Bug #5037

closed

empty AVT causes error "Cannot read property 'value' of null"

Added by Martin Honnen almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XSLT Conformance
Sprint/Milestone:
-
Start date:
2021-07-06
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

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