Project

Profile

Help

Support #4889

closed

Extra namespaces added when using the serialize function

Added by fouad MOUTASSIM about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
Start date:
2021-02-03
Due date:
% Done:

0%

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

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

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
Actions #1

Updated by Michael Kay about 3 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.

Actions #2

Updated by fouad MOUTASSIM about 3 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.

Actions #3

Updated by Michael Kay about 3 years ago

  • Status changed from In Progress to Closed

Please register to edit this issue

Also available in: Atom PDF