i want to change element name

Here should go questions about transforming XML with XSLT and FOP.
s.amitsaini
Posts: 3
Joined: Mon Jan 21, 2008 9:25 am

i want to change element name

Post by s.amitsaini »

i want to change element name......

i have xml file like that

<Project>
<Body>
<Title>
<TXT>Inside Title</TXT>
</Title>
<PLITEM>
<TXT>InSide The PLItem</TXT>
</PLITEM>
</Body>
</Project>



i want to change the name of element<PLITEM> to <ITEM>...want the output like that.....


<Project>
<Body>
<Title>
<TXT>Inside Title</TXT>
</Title>
<ITEM>
<TXT>InSide The PLItem</TXT>
</ITEM>
</Body>
</Project>
how its possible....?
sanderson
Posts: 51
Joined: Fri Jan 27, 2006 12:51 am

Re: i want to change element name

Post by sanderson »

Try using the (untested) XSLT below

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<!-- The identity transform -->
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="PLITEM">
<xsl:element name="ITEM">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>

</xsl:stylesheet>
Post Reply