Subject: RE: [xsl] How to change element nodes cases? From: Americo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx> Date: Mon, 31 Mar 2003 18:28:55 +0100 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to change element nod, G. Ken Holman | Thread | [xsl] Running server-side XSLT pars, Frankie Roberto |
RE: [xsl] generate full xpath name , Ray Tayek | Date | Re: [xsl] Cascading Menu (with Ope, Wendell Piez |
Month |