[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2003-03-30 17:42 -0800, Michael Liwanag wrote:
Remember with XSLT you are *not* changing nodes, you are building a result tree of nodes out of the source tree of nodes.
Therefore, in the push model, assuming you want attributes and content preserved, you would have a template for the result matched to the named node in the source:
If, however, you are changing the name on the way to the result while preserving the attributes, but also changing the names of other nodes on the way to the result, then you will need it to be slightly different as in the following modified node identity transform:
(I haven't checked the above for typos....)
I hope this helps.
................ Ken
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] How to change element nodes cases?
Subject: Re: [xsl] How to change element nodes cases? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 30 Mar 2003 21:58:43 -0500 |
At 2003-03-30 17:42 -0800, Michael Liwanag wrote:
How can I change this form: <customer> Michael </customer> to <Customer> Michael </Customer>
Remember with XSLT you are *not* changing nodes, you are building a result tree of nodes out of the source tree of nodes.
Therefore, in the push model, assuming you want attributes and content preserved, you would have a template for the result matched to the named node in the source:
<xsl:template match="customer"> <Customer> <xsl:copy-of select="@*"/> <xsl:copy-of select="node()"/> </Customer> </xsl:template>
If, however, you are changing the name on the way to the result while preserving the attributes, but also changing the names of other nodes on the way to the result, then you will need it to be slightly different as in the following modified node identity transform:
<xsl:template match="@*|node()"><!--node identity transform--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="customer"> <Customer> <xsl:apply-templates select="@*|node()"/> </Customer> </xsl:template> ... other node templates follow...
(I haven't checked the above for typos....)
I hope this helps.
................ Ken
-- Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO North America: June 16-20, 2003
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-10-1 Practical Formatting Using XSL-FO Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to change element nodes c, Michael Liwanag | Thread | RE: [xsl] How to change element nod, Americo Albuquerque |
[xsl] Running server-side XSLT pars, Frankie Roberto | Date | Re: [xsl] Running server-side XSLT , G. Ken Holman |
Month |