Support #4889

Extra namespaces added when using the serialize function

Added by fouad MOUTASSIM 8 months ago. Updated 7 months ago.

Saxon extensions
Start date:
Due date:
% Done:


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



we are trying to do an XML transform and when we call the serialization function to convert the XML result to a string we find some extra namespaces that we don't need. Could you please tell us how to get serialized result without additional namespaces. we are using the 10.4 release (saxon-ee-10.4.jar).

Please find attached the following:

  • The input (payload.xml)
  • The XSLT Map (Catalog_TO_GBO.xslt)
  • The result (Result.xml) and a screenshot (Result.JPG) with the namespaces marked in yellow

Thank you in advance.

Catalog_TO_GBO.xslt (2.93 KB) Catalog_TO_GBO.xslt fouad MOUTASSIM, 2021-02-03 19:41
payload.xml (1.18 KB) payload.xml fouad MOUTASSIM, 2021-02-03 19:41
Result.xml (1.97 KB) Result.xml fouad MOUTASSIM, 2021-02-03 19:41
Result.JPG (142 KB) Result.JPG fouad MOUTASSIM, 2021-02-03 19:41


#1 Updated by Michael Kay 8 months ago

  • Tracker changed from Bug to Support
  • Status changed from New to In Progress

If you want to avoid these namespaces appearing in the result, then you must ensure that they are not present in the tree that you are serializing. They are there because the elements were constructed as literal result elements, and the rules for literal result elements are that they get a copy of all in-scope namespaces declared in the stylesheet unless specified otherwise.

I normally include


in the xsl:stylesheet element to prevent this happening. It's very rare that this will exclude any namespaces that you actually need.

#2 Updated by fouad MOUTASSIM 8 months ago

Thank you for your help.

I made a copy of the tree that I want to serialize with the option copy-namespaces = "no" in a variable then I serialize the variable and it works fine now.

#3 Updated by Michael Kay 7 months ago

  • Status changed from In Progress to Closed

Please register to edit this issue

Also available in: Atom PDF