Bug #5951
closedXQuery with DOMResult - empty prefixed namespace bindings added to children elements
80%
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
Related issues
Please register to edit this issue