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

<?xml version="1.0" ?>

<Employee>
<EmployeeDetails EmployeeName="JohnnyWalker" EmployeeId="12345" CompanyName="ABC Inc." CompanyAddress="Bangalore" ContactNo="0000000" />
</Employee>

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

I want the output xml as:

<Employee>
<EmployeeDetails JohnnyWalker="12345" CompanyName="ABC Inc." CompanyAddress="Bangalore" ContactNo="0000000" />
</Employee>


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

Edited 6 Years Ago by soumya_mjmder: n/a

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>
This article has been dead for over six months. Start a new discussion instead.