p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: Changing the element name.


Message #1 by "Reshma Bhat" <reshmabhat@y...> on Wed, 12 Jun 2002 12:04:58
Hello sir,
   Thanks a lot for ur help. It's working fine.
Thank U.

> Write one template rule that copies elements unchanged:

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

and another that modifies the element name:

<xsl:template match="emp-name">
<xsl:element name="emp-info">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

Michael Kay
Software AG
home: Michael.H.Kay@n...
work: Michael.Kay@s... 

> -----Original Message-----
> From: Reshma Bhat [mailto:reshmabhat@y...] 
> Sent: 12 June 2002 12:05
> To: P2P_XSLT
> Subject: [xslt] Changing the element name.
> 
> 
> Hello,
>    I want to change the element name of certain element in a 
> XML document 
> & retain the same name as well as the values of remaining. 
> 
> For example my xml document is like this.
> 
>  <?xml version="1.0" encoding="UTF-8"?>
>  <jxtr-result>
>   <emp_info emp_id='1'>
>     <emp_name>Sachin</emp_name>
>     <address1>Anderi(west),</address1>
>     <address2>Mumbai</address2>
>     <salary>25000</salary>
>     <dept_id>4</dept_id>
>   </emp_info>
>   <emp_info emp_id='2'>
>     <emp_name>Ranjan</emp_name>
>     <address1>Katapadi</address1>
>     <address2>Udupi</address2>
>     <salary>40000</salary>
>     <dept_id>2</dept_id>
>   </emp_info>
>  </jxtr-result>
> 
> In the resulting document I want to change <emp_name> element to 
> <employee_info> but retaining the value & all other elements. 
> Can anyone help me out?
> 
> Thanks in advance.
> 
> ---
> Change your mail options at http://p2p.wrox.com/manager.asp or 
> to unsubscribe send a blank email to 
> 


  Return to Index