この変換:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:old="namespace_1" xmlns:new="namespace_2" >
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vOldNS" select=
"document('')/*/namespace::old"/>
<xsl:variable name="vNewNS" select=
"document('')/*/namespace::new"/>
<xsl:template match="*">
<xsl:choose>
<xsl:when test="namespace-uri()=$vOldNS">
<xsl:element name="{name()}" namespace="{$vNewNS}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
提供されたXMLドキュメントに適用した場合:
<cli:IWResource xmlns:cli="namespace_1">
<Name>MFCflowWithAdapter</Name>
<Type>process</Type>
<File>MFCflowWithAdapter.iwp</File>
<Description/>
<GUID>4C0BF41F-CB37-4815-B93F-1B6C2A103C6A</GUID>
<targetServer>6.1.5</targetServer>
<ImportedFrom>
<ServerURI>http://maria-ubuntu:9000</ServerURI>
<UserId>test</UserId>
<Password>ENCR(3157318131043128321832252993249)</Password>
<ImportDate>2012-07-26T16:22:52.644-04:00</ImportDate>
</ImportedFrom>
<Dependencies>
<Dependency>
<Name>RDBMS_oracle</Name>
<Type>adapter</Type>
<GUID>ACACF542E270035D7311E584E63F256C</GUID>
<Path>/aa</Path>
<UsageCount>1</UsageCount>
</Dependency>
</Dependencies>
</cli:IWResource>
必要な正しい結果を生成します:
<cli:IWResource xmlns:cli="namespace_2">
<Name>MFCflowWithAdapter</Name>
<Type>process</Type>
<File>MFCflowWithAdapter.iwp</File>
<Description/>
<GUID>4C0BF41F-CB37-4815-B93F-1B6C2A103C6A</GUID>
<targetServer>6.1.5</targetServer>
<ImportedFrom>
<ServerURI>http://maria-ubuntu:9000</ServerURI>
<UserId>test</UserId>
<Password>ENCR(3157318131043128321832252993249)</Password>
<ImportDate>2012-07-26T16:22:52.644-04:00</ImportDate>
</ImportedFrom>
<Dependencies>
<Dependency>
<Name>RDBMS_oracle</Name>
<Type>adapter</Type>
<GUID>ACACF542E270035D7311E584E63F256C</GUID>
<Path>/aa</Path>
<UsageCount>1</UsageCount>
</Dependency>
</Dependencies>
</cli:IWResource>