I have two XML files with two different XSD schemas and different namespaces. They have both an identical substructure. And now i need to copy that node (and all childs) from one XML document to the other one.
Clone would do, if the namespaces were the same. Is there a nice way to do it? (The substructure will change later on – but will be kept identical.)
Basically, you need an XSL transformation that creates new elements with equal names, but a different namespace.
Consider the following input XML:
Now you need a template that says ‘copy structure and name of everything you see, but declare a new namespace while you’re at it’:
When you run the above XML through it, this produces:
All your
http://tempuri.org/ns_oldelements have effectively changed their namespace. When your input XML has more than one namespace at the same time, the XSL must most likely be extended a bit.