namespace-alias_1-input.xml
<?xml version="1.0"?>
<products>
<name>Alpha</name>
<name>Bravo</name>
<name>Charlie</name>
<name>Delta</name>
</products>
namespace-alias_1-stylesheet.xsl
<?xml version="1.0"?>
<xsl:stylesheet
version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:jt="http://www.xmlplease.com/local" xmlns:please="http://www.xmlplease.com/ns1">
<xsl:output
indent="yes"/>
<xsl:namespace-alias
stylesheet-prefix="jt" result-prefix="please"/>
<xsl:template
match="/">
<jt:products>
<xsl:for-each
select="products/name">
<jt:name>
<xsl:value-of
select="."/>
</jt:name>
</xsl:for-each>
</jt:products>
</xsl:template>
</xsl:stylesheet>
namespace-alias_1-output.xml
<?xml version="1.0" encoding="UTF-8"?>
<please:products
xmlns:please="http://www.xmlplease.com/ns1">
<please:name>Alpha</please:name>
<please:name>Bravo</please:name>
<please:name>Charlie</please:name>
<please:name>Delta</please:name>
</please:products>
Let us say we have a huge XSLT stylesheet outputting to the xmlns:jt=http://www.xmlplease.com/ns1 namespace. We want to change the prefix to "please". Maybe only for one run of the stylesheet. The easy way is to rename the original namespace (above it is renamed to "local"), make a new namespace declaration with the new prefix and use the xsl:namespace-alias element to rename the old prefix to the new.
Updated 2009-03-19