Subject: Re: [xsl] Translating element names From: "Steve Muench" <Steve.Muench@xxxxxxxxxx> Date: Tue, 16 Jan 2001 09:50:21 -0800 |
This is a task for the Talented Identity Transform, the stylesheet that transform a document to itself. By augmenting the identity transformation: <!-- The Identity Transformation --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Whenever you match any node or any attribute --> <xsl:template match="node()|@*"> <!-- Copy the current node --> <xsl:copy> <!-- Including any attributes it has and any child nodes --> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> with an <xsl:template> that effects elements in the way that you want, all will be well. You'll end up with something like this: <!-- Transform a document to itself, lowercasing all tag names --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Import the identity transformation --> <xsl:import href="identity.xsl"/> <!-- When you match any element --> <xsl:template match="*"> <!-- Create the same element with a lowercase name --> <xsl:element name="{translate(name(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')}"> <!-- Including any attributes it has and any child nodes --> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> </xsl:stylesheet> ______________________________________________________________ Steve Muench, Lead XML Evangelist & Consulting Product Manager BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG Author "Building Oracle XML Applications", O'Reilly http://www.oreilly.com/catalog/orxmlapp/ ----- Original Message ----- From: "Thropp Lori" <lmt727@xxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, January 16, 2001 9:16 AM Subject: [xsl] Translating element names | I am having trouble writing an XSLT to do a simple | transformation task. I have lots of XML documents | that have there element tags as CAPITAL letters. I | need to write a XSLT to transform these XML documents | to contain all lowercase elements. It should be | relatively easy but I am having problems. I am still | new to writing XSLT and I am having trouble. Could | someone lend a hand or point me in the right | direction. | | Thank you. | | __________________________________________________ | Do You Yahoo!? | Get email at your own domain with Yahoo! Mail. | http://personal.mail.yahoo.com/ | | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list | | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Translating element names, Thropp Lori | Thread | RE: [xsl] Translating element names, Michael Kay |
Re: [xsl] XSLT to Find/Replace Chil, David Carlisle | Date | [xsl] How to copy all child element, Morris, Chris |
Month |