Project

Profile

Help

Bug #4353

closed

Extra namespaces present when serializing XdmValue using Serializer API

Added by Radu Coravu over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Serialization
Sprint/Milestone:
-
Start date:
2019-10-21
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
9.9
Fixed in Maintenance Release:
Platforms:

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

Also available in: Atom PDF