[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How to change element nodes cases?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|