Bug #4696


Different inherit-namespaces="no" result (10.2 and

Added by Air Quick almost 3 years ago. Updated over 2 years ago.

XSLT conformance
Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:


Given this test.xsl, Saxon 10.2 and behave differently.

$ cat test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="3.0" xmlns:x="x"

  <xsl:output indent="yes" />

  <xsl:template as="element(x:description)" name="xsl:initial-template">
    <xsl:element inherit-namespaces="no" name="description" namespace="x">
        <e />

$ java -jar SaxonHE9-9-1-7J/saxon9he.jar -it -xsl:test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="x">
   <x:scenario xmlns:x="x" xmlns="">
$ java -jar SaxonHE10-2J/saxon-he-10.2.jar -it -xsl:test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="x">
   <x:scenario xmlns:x="x">

10.2 doesn't set xmlns="" in <x:scenario>, whereas does.

Actions #1

Updated by Michael Kay almost 3 years ago

This change in behaviour is probably caused by the fix to bug #4666. I'll need to read the spec carefully to decide which is correct.

Actions #2

Updated by Air Quick almost 3 years ago

FWIW, 10.x worked in its way even before fixing #4666:

$ java -jar SaxonHE10-1J/saxon-he-10.1.jar -it -xsl:test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="x">
   <x:scenario xmlns:x="x">
$ java -jar SaxonHE10-0J/saxon-he-10.0.jar -it -xsl:test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="x">
   <x:scenario xmlns:x="x">
Actions #3

Updated by Michael Kay almost 3 years ago

I think the 9.9 results are correct.

The <e/> element, under the rules for namespaces on literal result elements, has a single namespace node, x = "x".

The <x:scenario/> element, by the same rules, also has a single namespace node, x = "x". Namespace inheritance is on for the construction of this element, but this does not cause any namespaces to be inherited by <e/>, because it already has all the relevant namespaces.

The <description> element, by the rules for xsl:element, including the namespace fixup rules, has a single namespace node, # = "x", where # represents the null prefix. Namespace inheritance is off, so this namespace is not inherited by the (copied) <x:scenario/> element.

During serialization, a namespace undeclaration should be added to the <x:scenario/> element because its parent has a namespace node for the default namespace, and the <x:scenario/> element does not.

Actions #4

Updated by Michael Kay almost 3 years ago

It doesn't seem to have anything to do with bug #4666 after all.

The NamespaceMaps that find their way through to the NamespaceDifferencer (on the serialization pipeline) are correct. The NamespaceDifferencer is making a conscious decision to add a namespace undeclaration for the default namespace only if the (child) element itself is in the default namespace.

I can't see any logic for this decision, and changing it doesn't appear to cause any tests to fail.

Adding the new test case as namespace-0913 in the XSLT3 test suite.

Actions #5

Updated by Michael Kay almost 3 years ago

  • Status changed from New to In Progress

The fix -- deleting the condition elementInDefaultNamespace at NamespaceDifferencer#100 -- seems sound. I won't commit it and close the issue until current reorganisation of the repository is complete.

Actions #6

Updated by Michael Kay over 2 years ago

Coming back to this, the test isn't failing even though the patch hasn't been applied and the result appear incorrect. I think that this is because the test suite driver isn't taking account of the namespace undeclaration xmlns="" when evaluating the assert-xml assertion. May need to use more explicit assertions (or improve the assert-xml logic).

Actions #7

Updated by Michael Kay over 2 years ago

I've changed the test to force serialization of the result tree, and to test the serialized output, and it now fails (as expected). This makes sense, because the NamespaceDifferencer is invoked only when we're performing serialization (or creating DOM trees, etc) - it's not needed if the result tree uses the XDM namespace model.

This also confirms that the patch to NamespaceDifferencer works.

Actions #8

Updated by Michael Kay over 2 years ago

  • Category set to XSLT conformance
  • Status changed from In Progress to Resolved
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch 10, trunk added
  • Fix Committed on Branch 10, trunk added
Actions #9

Updated by O'Neil Delpratt over 2 years ago

Bug fix applied in the Saxon 10.3 maintenance release

Actions #10

Updated by O'Neil Delpratt over 2 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.3 added

Please register to edit this issue

Also available in: Atom PDF