Subject:XSLT Transformation w/ namespaces Author:James Hughes Date:06 Feb 2008 11:17 AM
I am trying to get a XSLT that will transform both of the following cases:
Case 1
Input Xml
<a xmlns="tempURI.org"><b xmlns="abc.org">1<b></a>
Output Xml
<a xmlns="newURI.org"><b xmlns="abc.org">1<b></a>
and
Case 2
Input Xml
<tmp:a xmlns:tmp="tempURI.org"><b xmlns="abc.org">1<b></tmp:a>
Output Xml
<a xmlns="newURI.org"><b xmlns="abc.org">1<b></a>
Note: The child elements of the root element could be any number of elements in any namespace. If the elements are in the target's default namespace, the elements should not have a prefix.
How would you handle the issue of the child elements of the root element that are in the tempURI.org namespace but in the target they should be in the newURI.org namespace like the root element?
Example
Case 1
Input Xml
<a xmlns="tempURI.org"><b xmlns="abc.org">1<b><c>2</c></a>
Output Xml
<a xmlns="newURI.org"><b xmlns="abc.org">1<b><c>2</c></a>
and
Case 2
Input Xml
<tmp:a xmlns:tmp="tempURI.org"><b xmlns="abc.org">1<b><tmp:c>2</tmp:c></tmp:a>
Output Xml
<a xmlns="newURI.org"><b xmlns="abc.org">1<b><c>2</c></a>