[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Help renaming attributes


Subject: RE: [xsl] Help renaming attributes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 6 Oct 2005 14:55:34 +0100

You want <xsl:attribute name="{expr}"> for a dynamically-specified name.
Note the curlies.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Nadia.Swaby@xxxxxx [mailto:Nadia.Swaby@xxxxxx] 
> Sent: 06 October 2005 14:26
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Help renaming attributes
> 
> Hi All,
> 
> I am trying to convert a structured Framemaker document to 
> and XML document
> that validates against our customized DTD.  When I convert a 
> Framemaker
> document to XML, any elements with id attributes look like this:
> 
> <figure Id="i494943"></figure>
> 
> I would like to change this (and all attributes) to lower case, for
> example:
> 
> <figure id="i494943"></figure>
> 
> I tried using this code (XSLT 2.0 with Saxon 8 .5):
> 
> <xsl:copy>
>       <xsl:for-each select="@*">
>             <xsl:attribute name="lower-case(name(.))">
>                   <xsl:value-of select="."/>
>             </xsl:attribute>
>       </xsl:for-each>
>       <xsl:apply-templates/>
> </xsl:copy>
> 
> and this
> 
> <xsl:copy>
>       <xsl:for-each select="@*">
>             <xsl:variable name="attrname" 
> select="lower-case(name(.))"/>
>             <xsl:attribute name="$attrname">
>                   <xsl:value-of select="."/>
>             </xsl:attribute>
>       </xsl:for-each>
>       <xsl:apply-templates/>
> </xsl:copy>
> But in both cases I get the error message "Attribute name is 
> not a valid
> QName".
> 
> Is there any way to work around this?
> 
> Thanks
> 
> Nadia


Current Thread
Keywords
xml