Support #4889
closedExtra namespaces added when using the serialize function
0%
Description
Hi,
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.
Files
Updated by Michael Kay almost 4 years 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
exclude-result-prefixes="#all"
in the xsl:stylesheet
element to prevent this happening. It's very rare that this will exclude any namespaces that you actually need.
Updated by fouad MOUTASSIM almost 4 years 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.
Updated by Michael Kay over 3 years ago
- Status changed from In Progress to Closed
Please register to edit this issue