[xsl] How to give an attribute a QName value, with the appropriate prefix?

Subject: [xsl] How to give an attribute a QName value, with the appropriate prefix?
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Mon, 27 Aug 2012 20:37:29 +0000
Hi Folks,

I want to transform this:

    <xs:attribute name="test" />

to this:

      <xs:attribute name="test" type="xs:anySimpleType" />

Here is the code that I tried:

    <xsl:template match="xs:attribute">
        <xsl:copy>
            <xsl:copy-of select="@*" />
            <xsl:attribute name="type"><xsl:value-of
select="QName('http://www.w3.org/2001/XMLSchema', 'anySimpleType')"
/></xsl:attribute>
            <xsl:sequence select="node()" />
        </xsl:copy>
    </xsl:template>

Unfortunately that code produces this:

      <xs:attribute name="test" type="anySimpleType" />

Notice that there is no prefix on anySimpleType.

What's the best way to accomplish my objective?

I want the prefix on anySimpleType to match the prefix on the <attribute>
element, whether it be xs: or xsd: or anything else.

/Roger

Current Thread