ElementAdd.xml

<?xml version = "1.0" encoding = "UTF-8"?>

<factory>

    <item>

        <name>Toy</name>

        <buyingPrice>6</buyingPrice>

        <sellingPrice>10</sellingPrice>

    </item>

 

    <item>

        <name>Box</name>

        <buyingPrice>4</buyingPrice>

        <sellingPrice>8</sellingPrice>

    </item>

 

    <item>

        <name>Bag</name>

        <buyingPrice>60</buyingPrice>

        <sellingPrice>100</sellingPrice>

    </item>

</factory>

ElementAdd.xsl

<?xml version = "1.0" encoding = "UTF-8"?>

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

<xsl:template match = "/factory">

      <item>

         <xsl:apply-templates select = "item"/>

      </item>

</xsl:template>

<xsl:template match = "item">

       <xsl:text>&#10;</xsl:text>

       <name>

      <xsl:value-of select="name"/>

       </name>

      <xsl:element name = "profit">

       <xsl:value-of select="(sellingPrice -buyingPrice)"/>      

      </xsl:element>

      <xsl:text>&#10;</xsl:text>

</xsl:template>

</xsl:stylesheet>

Output.xml

<?xml version="1.0"?>

<item>

<name>Toy</name><profit>4</profit>

<name>Box</name><profit>14</profit>

<name>Bag</name><profit>40</profit>

</item>