[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: template to convert all attributes' name to lowerc

Subject: Re: template to convert all attributes' name to lowercase
From: Heping Zhang <phoenix.zhp@xxxxxxxxx>
Date: Thu, 28 May 2009 16:54:37 +0800
Re:  template to convert all attributes' name to lowerc
thank you Xmlizer! In the file, one element just have one attribute of
the certain name. I just need to standlize case of name otherwise the
workflow designer rejects to open the file.
Still thank you very much!

2009/5/28 Xmlizer <xmlizer+xsllist@xxxxxxxxx>:
> Well
> Well
>
> The answer is more or less the one proposed by Mike
>
> <xsl:stylesheet version="2.0"
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>    <xsl:template match="*">
>        <xsl:element name="{lower-case(name())}"
namespace="{namespace-uri()}">
>            <xsl:apply-templates select="@* | node()"/>
>        </xsl:element>
>    </xsl:template>
>
>    <xsl:template match="@*">
>        <xsl:attribute name="{lower-case(name())}"
> namespace="{namespace-uri()}">
>            <xsl:value-of select="."/>
>        </xsl:attribute>
>    </xsl:template>
>
> </xsl:stylesheet>
>
> Buy anyway, you have to take care about the fact that if you have
> attribute with name that only differ by case, you might end up being
> surprise by the result
>
> Xmlizer
>
> On Thu, May 28, 2009 at 10:04 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>>
>>> I hava a task to convert all attributes' name in a xslt file
>>> to lowercase. Actually I don't know whether it's a xslt file.
>>
>> It's not an XSLT file, it's a stylesheet written in an obsolete Microsoft
>> language (often called WD-xsl) that was based on an early draft of XSLT,
>> with Microsoft additions and deletions.
>>
>>> It looks strange, like this:
>>> <?xml version="1.0"?>
>>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
>>>       <xsl:template match=" / ">
>>>               <HTML>
>>>                       <BodY bgColor="#c0c0c0" Class="screen"
>>> FNSType="SINGLEPAGESCREEN"
>>> id="FNSScreen">
>>>                       //many html things go here.
>>>                       </BodY>
>>>               </HTML>
>>>       </xsl:template>
>>> </xsl:stylesheet>
>>
>>> I'm a novice of  xslt and have only two days to finish this task.
>>
>> Usually if a task is urgent and the user is a novice I reckon the best
>> advice I can give is "don't even attempt it, you will only make a mess of
>> it". However this one is fairly easy. I suspect you want to change the
>> element names to lower-case too? That's essentially a modified identity
>> stylesheet:
>>
>> <xsl:stylesheet version="2.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>
>>  <xsl:template match="*">
>>    <xsl:element name="lower-case(name())" namespace="{namespace-uri()}">
>>      <xsl:apply-templates select="@* | node()"/>
>>    </xsl:element>
>>  </xsl:template>
>>
>>  <xsl:template match="@*">
>>    <xsl:attribute name="lower-case(name())" namespace="{namespace-uri()}">
>>      <xsl:value-of select="."/>
>>    </xsl:element>
>>  </xsl:template>
>>
>> </xsl:stylesheet>
>>
>> That solution uses XSLT 2.0. If for some reason you have to use XSLT 1.0,
>> you can replace
>>
>> lower-case(X)
>>
>> by
>>
>> translate(X, 'ABCDE....Z', 'abcde....z')
>>
>> Regards,
>>
>> Michael Kay
>> http://www.saxonica.com/
>> http://twitter.com/michaelhkay

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.