Project

Profile

Help

Bug #4696

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

Added by Air Quick over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2020-08-26
Due date:
% Done:

100%

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

Description

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

$ cat test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="3.0" xmlns:x="x"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output indent="yes" />

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

</xsl:stylesheet>
$ 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="">
      <e/>
   </x:scenario>
</description>
$ 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">
      <e/>
   </x:scenario>
</description>
$ 

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

History

#1 Updated by Michael Kay over 1 year 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.

#2 Updated by Air Quick over 1 year 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">
      <e/>
   </x:scenario>
</description>
$ 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">
      <e/>
   </x:scenario>
</description>

#3 Updated by Michael Kay over 1 year 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.

#4 Updated by Michael Kay over 1 year 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.

#5 Updated by Michael Kay over 1 year 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.

#6 Updated by Michael Kay about 1 year 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).

#7 Updated by Michael Kay about 1 year 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.

#8 Updated by Michael Kay about 1 year 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

#9 Updated by O'Neil Delpratt about 1 year ago

Bug fix applied in the Saxon 10.3 maintenance release

#10 Updated by O'Neil Delpratt about 1 year 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