Project

Profile

Help

Bug #4937

closed

Extra NS declaration added by transformer

Added by Taras Chervinka over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DOM Interface
Sprint/Milestone:
-
Start date:
2021-03-15
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

<a xmlns='someNS' name='test'><b xmlns=''/></a>

is transformed into

<a xmlns='someNS' name='test'><b xmlns='' xmlns=''/></a>

which is not valid

org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 24; Attribute "xmlns" was already specified for element "b".

see test case attached. That works fine with 9.9 (HE, EE)

java -cp saxon9he.jar;.  testSaxonTransformer

but fails with 10.0-10.3 (HE, EE) also tried with EE 10.4

java -cp saxon-he-10.3.jar;.  testSaxonTransformer

but the transformed is correct when I add another NS. Like:

<a xmlns='someNS' xmlns:z='z' name='test'><b xmlns=''/></a>

Files

testSaxonTransformer.java (1.54 KB) testSaxonTransformer.java Taras Chervinka, 2021-03-15 14:36
Actions #1

Updated by Michael Kay over 3 years ago

  • Category set to DOM Interface
  • Status changed from New to In Progress
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch trunk added

Thanks for reporting it.

Reproduced as JUnit test testNamespaceSerializationBug4937().

Actions #2

Updated by Michael Kay over 3 years ago

The error appears to be when combining two namespace maps (NamespaceMap.applyDifferences() -- which is not actually DOM-specific code, though it's probably used rather differently when handling DOM input.). This ends up incorrectly generating an empty namespace map for element b, rather than a map containing the single namespace binding (""=""). This error is then compounded: because the namespace map is empty, the scan of attributes on element b doesn't check whether any of the attributes are actually namespaces, so it's processing xmlns:"" a second time as if it were an ordinary attribute.

Actions #3

Updated by Michael Kay over 3 years ago

I've applied a fix to NamespaceMap.applyDifferences() on the 10.x branch which ensures this test now passes. However, the test passes on the 11.x branch without this change: I'm currently exploring why.

Actions #4

Updated by Michael Kay over 3 years ago

  • Status changed from In Progress to Resolved
  • Fix Committed on Branch 10, trunk added

It was working on the 11.x branch because my configuration settings meant I was picking up Xalan as the DOM identityTransformer. Fixed this, found the bug was still present, so I've applied the patch to both branches.

Actions #5

Updated by O'Neil Delpratt over 3 years ago

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

Bug fix applied to Saxon 10.5 maintenance release.

Please register to edit this issue

Also available in: Atom PDF