954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

change of attribute value in xml using xsl

Hi..i am new with xml and xsl.
I have the input xml as:

<?xml version="1.0" ?>

--------------------------------------------

I want the output xml as:


i need to do this using xsl.....can anybody please help??

soumya_mjmder
Newbie Poster
13 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Here is one way of doing it.

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

<xsl:output method="xml"/>


<xsl:template match="Employee">
   <Employee>
   <xsl:apply-templates select="EmployeeDetails" />
   </Employee>
</xsl:template>


<xsl:template match="EmployeeDetails">
     <xsl:variable name="employee" select="@EmployeeName" />
     <xsl:variable name="id"  select="@EmployeeId" />
     <xsl:element name="EmployeeDetails">
        <xsl:attribute name="{$employee}"><xsl:value-of select="$id" /></xsl:attribute>
        <xsl:attribute name="CompanyName"><xsl:value-of select="@CompanyName" /></xsl:attribute>
        <xsl:attribute name="CompanyAddress"><xsl:value-of select="@CompanyAddress" /></xsl:attribute>
        <xsl:attribute name="ContactNo"><xsl:value-of select="@ContactNo" /></xsl:attribute>
     </xsl:element>
</xsl:template>


</xsl:stylesheet>
fpmurphy
Junior Poster
147 posts since Oct 2008
Reputation Points: 22
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: