|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to change element nodes cases?
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
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
|
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
|

Cart








