RE: [xsl] How to take a QName value and make it an attribute?

Subject: RE: [xsl] How to take a QName value and make it an attribute?
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Wed, 1 Aug 2012 16:02:51 +0000
Thanks Andrew, Andrew, Michael, and David.

With this input:

    <fault>soap:client</fault>

This template rule:

    <xsl:template match="fault">
        <xsl:copy>
            <xsl:variable name="q" as="xs:QName" select="resolve-QName(., .)"
/>
            <xsl:attribute name="{$q}"
namespace="{namespace-uri-for-prefix(prefix-from-QName($q),
.)}">blah</xsl:attribute>
            <xsl:value-of select="." />
        </xsl:copy>
    </xsl:template>

Produces this output:

    <fault xmlns:soap="http://www.soap.org";
soap:client="blah">soap:client</fault>

Perfect!

Exactly what I want.

/Roger

Current Thread