Bug #4681

namespace declaration not honored: error XTDE1390 undeclared prefix: saxon

Added by Martin Honnen about 1 month ago. Updated 1 day ago.

In Progress
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:


When I run the file

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl=""

  <xsl:output method="text"/>

  <xsl:template name="xsl:initial-template">
    <xsl:text xmlns:saxon="">Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('saxon:platform')}</xsl:text>


with Saxon-JS 2 under Node (using xslt3 -it -xsl) I get an error:

Transformation failure: Error XTDE1390 at ns-problem2.xsl#10
    Undeclared prefix: saxon
Transformation failed: Error XTDE1390 at ns-problem2.xsl#10
    Undeclared prefix: saxon

The namespace is declared on the xsl:text element so I think this is a bug. Running the stylesheet through Saxon HE 10.1 Java does not give any error.

Moving the namespace declaration to the stylesheet's root element enables Saxon-JS to run the code but I think it should work with the local namespace declaration as well.


#1 Updated by Debbie Lockett 3 days ago

  • Assignee set to Michael Kay

#2 Updated by Michael Kay 2 days ago

  • Status changed from New to In Progress

Added XSLT3 test case system-property-025, which adapts the repro by binding a different prefix locally to the XSLT namespace.

#3 Updated by Michael Kay 2 days ago

Confirmed that the new test is failing under latest Saxon-JS build.

#4 Updated by Michael Kay 2 days ago

In the SEF file, the call on system-property is output with

"ns": "= xml=~ fn=~ xsl=~ xs=~ ",

indicating that the namespace declaration on the xsl:text element has been lost.

#5 Updated by Michael Kay 2 days ago

In the static phase (static.xsl#702) an xsl:text element is replaced by its content, which loses the namespace declarations. It also probably loses other attributes that might affect the interpretation of TVTs within the xsl:text element, for example @version or @default-collation.

#6 Updated by Michael Kay 2 days ago

First attempt to fix this by passing the xsl:text through to the next phase using xsl:next-match, and picking it up in the sef phase along with xsl:value-of at creating-new-nodes#279 was unsuccessful.

(Trying to remember how to debug the compiler, haven't done it for a while...)

#7 Updated by Michael Kay 1 day ago

Now working (though I need to do some clearing up before committing, to get rid of temporary diagnostics, and to do some regression testing).

The changes to the XX compiler are:

  • In static.xsl, in the match="xsl:text" template, call xsl:next-match so the xsl:text element survives into the mode="sef" phase.

  • In creating-new-nodes.xsl, in the match="xsl:text[normalize-space()]" template, apply-templates with mode attribute-sans-prefix to process attributes appearing on the xsl:text element.

#8 Updated by Michael Kay 1 day ago

  • Status changed from In Progress to Resolved
  • Priority changed from Low to Normal
  • Fix Committed on JS Branch Trunk added

#9 Updated by Debbie Lockett 1 day ago

  • Status changed from Resolved to In Progress

Reopening because I'm seeing regression. E.g. xslt30 axes test set. Reverting the change in static.xsl for the match="xsl:text" template, means the axes tests pass again, but t=system-property-025 fails.

Please register to edit this issue

Also available in: Atom PDF Tracking page