Project

Profile

Help

Bug #5196

closed

Missing default namespace attribute on transform to DOM

Added by Mário Martinho Dias almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DOM Interface
Sprint/Milestone:
-
Start date:
2022-01-03
Due date:
% Done:

100%

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

Description

There seems to be an issue with Java Saxon-HE 10 when handling default namespace declarations in some circumstances when transforming to DOM, the attribute is missing from the actual model.

TransformerFactory transformerFactory = new net.sf.saxon.TransformerFactoryImpl();
DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newDefaultInstance();
documentFactory.setNamespaceAware(true);

Document document = documentFactory.newDocumentBuilder().newDocument();
DOMResult result = new DOMResult(document);

String xml =
		  "<X xmlns=\"FOO\" xmlns:b=\"BAR\">"
		  + "<Y xmlns=\"\"/>"
		+ "</X>";

transformerFactory.newTransformer().transform(new StreamSource(
		new StringReader(xml)), result);
// X/Y@xmlns
assertNotNull(document.getDocumentElement().getChildNodes().item(0)
		.getAttributes().getNamedItem("xmlns"));

This was the specific behavior that I caught, latest 9.9 and 10.0 pass this test, 10.1 onwards doesn't.

If I remove both namespace declarations from "X" it also fails in version 10.0.


Files

saxon-test.zip (2.88 KB) saxon-test.zip testcase Mário Martinho Dias, 2022-01-03 15:15

Please register to edit this issue

Also available in: Atom PDF