xsl-list
[Top] [All Lists]

RE: [xsl] [XSLT 1.0] Replace namespace prefixes?

2009-12-24 13:06:47


Ken Holman gave this solution to the "replace prefixes problem": 

---------------------------------------------------
?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

    <xsl:param name="use-this-prefix" />

    <xsl:template match="*[namespace-uri(.)]">

        <xsl:element name="{$use-this-prefix}:{local-name()}"
                     namespace="{namespace-uri(.)}">
            <xsl:apply-templates select="@*|node()"/>
        </xsl:element>

    </xsl:template>

    <xsl:template match="@*[namespace-uri(.)]">

        <xsl:attribute name="{$use-this-prefix}{local-name()}"
                       namespace="{namespace-uri(.)}">
            <xsl:value-of select="."/>
        </xsl:attribute>

    </xsl:template>


    <xsl:template match="@*|node()"><!--identity for all other nodes-->

        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>

    </xsl:template>

</xsl:stylesheet>
---------------------------------------------------

Wow! You da man Ken! That works beautifully. Thank you! 

Happy Holidays!

/Roger
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--