Subject: Re: [xsl] How to give an attribute a QName value, with the appropriate prefix? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 27 Aug 2012 16:41:24 -0400 |
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.
(untested) <xsl:attribute name="{prefix-from-QName(node-name(.))}:anySimpleType" namespace="http://www.w3.org/2001/XMLSchema"> <xsl:copy-of select="node()"/> </xsl:attribute>
-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to give an attribute a QN, Costello, Roger L. | Thread | Re: [xsl] How to give an attribute , G. Ken Holman |
[xsl] How to give an attribute a QN, Costello, Roger L. | Date | Re: [xsl] How to give an attribute , Imsieke, Gerrit, le- |
Month |