| Subject: [xsl] RE: How to give an attribute a QName value, with the  appropriate prefix? From: "Costello, Roger L." <costello@xxxxxxxxx> Date: Tue, 28 Aug 2012 11:45:29 +0000 | 
Thanks Gerrit and Ken.
This works great:
    <xsl:template match="xs:attribute">
          <xsl:copy>
                <xsl:copy-of select="@*" />
                <xsl:variable name="prefix"
select="prefix-from-QName(node-name(.))" />
                <xsl:attribute name="type"><xsl:value-of
select="concat($prefix, if ($prefix eq '') then 'anySimpleType' else
':anySimpleType')" /></xsl:attribute>
                <xsl:sequence select="node()" />
          </xsl:copy>
    </xsl:template>
/Roger
-----Original Message-----
From: Costello, Roger L.
Sent: Monday, August 27, 2012 4:37 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: How to give an attribute a QName value, with the appropriate prefix?
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 | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] How to give an attribute , Imsieke, Gerrit, le- | Thread | [xsl] XSL Navigation Choose Test, Voltmer, Steve T | 
| Re: [xsl] How to give an attribute , G. Ken Holman | Date | [xsl] A way to test only top level , Voltmer, Steve T | 
| Month |