Project

Profile

Help

Bug #5951

closed

XQuery with DOMResult - empty prefixed namespace bindings added to children elements

Added by Steven Dürrenmatt about 1 year ago. Updated 5 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
DOM Interface
Sprint/Milestone:
-
Start date:
2023-04-01
Due date:
% Done:

80%

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

Description

Hello,

From Saxon 10 I have failing tests for XQuery transformations that deal with elements without namespace attribute. Such elements can inherit their parent namespace prefix and the namespace binding is reassigned the empty value.

Example of a basic XQuery transformation that does not need any context to be evaluated:

DOMResult result = new DOMResult();
Configuration config = new Configuration();
XQueryExpression expression = config.newStaticQueryContext().compileQuery("declare namespace b = 'test';<b:book><title/></b:book>");
expression.run(new DynamicQueryContext(config), result, new Properties());

Document doc = (Document) result.getNode();
StringWriter sw = new StringWriter();
Transformer transformer = new TransformerFactoryImpl().newTransformer();
transformer.transform(new DOMSource(doc), new StreamResult(sw));

System.out.println(sw);

That should output:

<?xml version="1.0" encoding="UTF-8"?><b:book xmlns:b="test"><title/></b:book>

But we have the following invalid XML instead:

<?xml version="1.0" encoding="UTF-8"?><b:book xmlns:b="test"><title xmlns:b=""/></b:book>

It works as expected if you use a StreamBuffer from a byte stream instead of a DOMResult. Another workaround is to redeclare the namespace inside the XML in the transformation, however that does not work for more complex transformations where the XML could be splitted into different functions. Any suggestion is welcome.


Files

clipboard-202304011320-pjfuf.png (76.1 KB) clipboard-202304011320-pjfuf.png Steven Dürrenmatt, 2023-04-01 13:20

Related issues

Has duplicate Saxon - Bug #6173: Namespace with empty uri when using Saxon-11.5DuplicateMichael Kay2023-08-16

Actions

Please register to edit this issue

Also available in: Atom PDF