[XML Records] Handling namespaces with XML Records

[XML Records] Handling namespaces with XML Records

Forge Component
Published on 2016-06-15 by Ricardo Silva
27 votes
Published on 2016-06-15 by Ricardo Silva
Pedro Miranda wrote:
is it possible to tranform the first node from something like



<n1:Group xmlns:ns1="http://..." xmlns:n1="http://...">

using the configuration file?
No, it isn't.
The configuration file only allows you to add a xmlns attribute to a particular element.
It would make it possible to transform 
<Group xmlns="http://blabla">

which semantically is the same as what Pedro was trying to achieve, only that you don't name that particular element.
To do what Pedro is requesting, you'd have to do some kind of post processing to the XML text.

An approach I usually use is to name my attributes with a prefix (e.g. call it n1Group instead of Group) and afterwards replace all existences of n1Group with n1:Group.

All the namespace declarations are usually added in the first xml element. Something like

<xml xmlns:n1="http://blabla">

There is some processing overhead... but usually not relevant unless you're dealing with very large XML files, in which case, this extension might not be the best approach, as you should use an XML Reader/Writer approach instead.
Hi Goncalo,
I am using record to xml and the generated xml doesnt have namespace. Could you please let me know how to add the namespaces to the xml.