I hope you can help... Let's assume I have following XML:
<data>
<token>
<sessionId>12345</sessionId>
<userId>john</userId>
<moreInfo>
<bla> .....
</bla>
</moreInfo>
</token>
</data>
And I need this to become
<login:data xmlns:login="http://my.ns.uri">
<login:token>
<login:sessionId>12345</sessionId>
<login:userId>john</userId>
<login:moreInfo>
<login:bla> .....
</login:bla>
</login:moreInfo>
</login:token>
</login:data>
Can I do this with XSL? I did try but failed miserably ... Any help would be greatly appreciated!
Thanks, Jan
XSLT 2.0 is more efficient and compact. It supports to add namespaces to node directly. We don't need to define anything in the starting of stylesheet as well.
Here is the spec : creating namespace prefix
Use :
It will give the output :
Use:
When this transformation is applied on the provided XML document, the wanted, correct result is produced: