Bug #5037


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

Added by Martin Honnen about 3 years ago. Updated almost 3 years ago.

XSLT Conformance
Start date:
Due date:
% Done:


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


The spec 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=""

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/" name="xsl:initial-template">
      <xsl:variable name="element-name" select="'foo'"/>
      <xsl:element name="{$element-name}" namespace="{}">test</xsl:element>
    <xsl:comment>Run with <xsl:value-of select="system-property('xsl:product-name')"/>; <xsl:value-of select="system-property('xsl:product-version')"/></xsl:comment>


gives an error "Cannot read property 'value' of null".

The code runs fine with Saxon Java, I think Saxon-JS has a bug here.

Actions #1

Updated by Martynas Jusevicius about 3 years ago

What version of Node.js? I had a somewhat similar issue which was due to an old version of it:

Actions #2

Updated by Martin Honnen about 3 years ago

Node 14, I think. But happens in the browser as well.

Actions #3

Updated by Debbie Lockett about 3 years ago

  • Status changed from New to In Progress

Thanks for providing the repro. Indeed this is a problem which only arises with an XX-compiled stylesheet (i.e. exported with Saxon-JS on Node.js, rather than with Saxon-EE). The stylesheet XX-compiles to SEF, but then there is a runtime failure, which results in the error "Transformation failure: TypeError: Cannot read property 'value' of null".

Specifically, the error is thrown while processing the compElem expression which contains

  "N": "empty",
  "sType": "0 ",
   "role": "namespace"

because it is (wrongly) assumed that the result of this namespace expression is non-empty.

I will add a test to the XSLT3 test suite. Note that there are other tests for empty AVTs (e.g. avt-2102 has an empty AVT on a literal result element, and this test passes), but no test for this specific case (empty AVT for the namespace attribute of xsl:element).

Actions #4

Updated by Debbie Lockett about 3 years ago

  • Status changed from In Progress to Resolved
  • Fix Committed on JS Branch 2 added

XSLT3 test avt-2103 added, and fix committed in computedQNameEvaluator in Push.js.

Actions #5

Updated by Debbie Lockett almost 3 years ago

  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 2.3

Bug fix applied in the Saxon-JS 2.3 maintenance release.

Actions #6

Updated by Debbie Lockett almost 3 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF Tracking page