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

RE: How to change element nodes cases?

Subject: RE: How to change element nodes cases?
From: Americo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Mon, 31 Mar 2003 18:28:55 +0100
xsl case change
Hi.

> -----Mensagem original-----
> De: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] Em nome de 
> Michael Liwanag
> Enviada: segunda-feira, 31 de Marco de 2003 2:42
> Para: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Assunto:  How to change element nodes cases?
> 
> 
> How can I change this form:
> <customer> Michael </customer>
> to 
> <Customer> Michael </Customer>
> 

This template will change the case of all your elements:
 <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
 <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
 
 <xsl:template match="*">
  <xsl:variable name="pref"
select="substring-before(name(),local-name())"/>
  <xsl:element
name="{concat($pref,translate(substring(local-name(),1,1),$lower,$upper)
,translate(substring(local-name(),2),$upper,$lower))}"
namespace="{namespace-uri()}">
   <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>

Applyied to this source:
<doc xmlns:y="test2">
 <costumer>
  <prep/>
 </costumer>
 <test/>
 <x:test xmlns:x="test1"/>
 <x:opps xmlns:x="test1">
  <y:test/>
 </x:opps>
</doc>

Result in this:
<Doc>
 <Costumer>
  <Prep/>
 </Costumer>
 <Test/>
 <x:Test xmlns:x="test1"/>
 <x:Opps xmlns:x="test1">
  <y:Test xmlns:y="test2"/>
 </x:Opps>
</Doc>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.