How can I copy some of the attributes from a node.For Ex. I want to copy only "Srno" ,"RollNo" ,"right" from node "Extn".
<Main>
<SubMainLevel1 material="12" feature="range">
<SubMainLevel2 arg1="abc" arg2="123">
<Item name="hello" desc="one" />
<Detail long="high" short="wide" />
<Extn Srno="12" RollNo="12" weight="12" folds="2" right="Y" left="N" top="T" bottom="V" />
</SubMainLevel2>
<SubMainLevel2 arg1="cyz" arg2="123">
<Item name="hello2" desc="two" />
<Detail long="short" short="wide" />
<Extn Srno="" RollNo="" weight="" folds="1" right="Y" left="N" top="T" bottom="V" />
</SubMainLevel2>
</SubMainLevel1>
</Main>
The Xsl I am using is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*" />
<xsl:template match="/">
<Job>
<xsl:copy-of select="Main/SubMainLevel1/@*[name()='material']" />
<Lines>
<xsl:for-each select="/Main/SubMainLevel1/SubMainLevel2">
<xsl:if test="@arg2 = '123'">
<Line>
<xsl:copy-of select="@*" />
<xsl:copy-of select="node()[name() = 'Item']" />
<xsl:copy-of select="node()[name() = 'Detail']" />
<xsl:copy-of select="node()[name() = 'Extn']" />
</Line>
</xsl:if>
</xsl:for-each>
</Lines>
</Job>
</xsl:template>
</xsl:stylesheet>
Here how can I restrict node "Extn" with only above mentioned values.
Expected Output is
<?xml version="1.0" encoding="UTF-8"?>
<Job material="12">
<Lines>
<Line arg1="abc" arg2="123">
<Item name="hello" desc="one" />
<Detail long="high" short="wide" />
<Extn Srno="12" RollNo="12" right="Y"/>
</Line>
<Line arg1="cyz" arg2="123">
<Item name="hello2" desc="two" />
<Detail long="short" short="wide" />
<Extn Srno="" RollNo="" right="Y"/>
</Line>
</Lines>
</Job>
Note: This is not same as "How not to copy some attributes?"