Bug #4353
closed![Author: Radu Coravu](https://www.gravatar.com/avatar/765896f3e900dbcce565dbf8425cc7e7?rating=PG&size=50&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
![Assignee: Michael Kay](https://www.gravatar.com/avatar/db6526d63053f09b62e52c2da8b2230a?rating=PG&size=22&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
Extra namespaces present when serializing XdmValue using Serializer API
0%
Description
I have an "net.sf.saxon.s9api.XdmValue" which resulted from an XQuery update operation. I create a serializer "net.sf.saxon.s9api.Processor.newSerializer(Writer)" and then use it to serialize the value:
serializer.serializeXdmValue(rootElement);
Problem is that with Saxon 9.9 I get extra not-necessary namespaces serialized, something like:
<p:url href="http://www.example.com" xmlns:p="http://www.oxygenxml.com/ns/samples/personal"/>
so I would prefer somehow to have an extra namespace reducer when writing the content.
I looked at the implementation of "net.sf.saxon.s9api.Processor.writeXdmValue(XdmValue, Destination)" which seems to be adding a namespace reducer on the "else" clause so I used the following workaround on my side:
processor.writeXdmValue(rootElement, new AbstractDestination() {
@Override
public Receiver getReceiver(PipelineConfiguration pipe, SerializationProperties params)
throws SaxonApiException {
return serializer.getReceiver(pipe, params);
}
@Override
public void close() throws SaxonApiException {
serializer.close();
}
});
to force the code on the "else" branch and add that extra namespace reducer. But maybe "serializer.serializeXdmValue(rootElement);" could by default somehow use an namespace reducer by default.
Please register to edit this issue