xsl-list
[Top] [All Lists]

Problem Copying an element, always getting first in the list

2005-02-08 08:52:03
<Tests>
        <Test>
        <ASIN>12334</ASIN>
        <Attributes>
                <Name>Sian</Name>
                <Type>th</Type>
        </Attributes>
        </Test>
        <Test>
        <ASIN>54321</ASIN>
        <Attributes>
                <Name>JIM</Name>
                <Type>th</Type>
        </Attributes>
        </Test>
</Tests>

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml"/>

<xsl:template match="@*|node()">
       <xsl:copy>
           <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
</xsl:template>

<xsl:template match="/Tests/Test/Attributes">
   <xsl:copy>
           <xsl:apply-templates select="@*|node()"/>
       <asin><xsl:value-of select="/Tests/Test/ASIN"/></asin>
       </xsl:copy>
   </xsl:template>

</xsl:stylesheet>

I would like the output to be the following

<Tests>
        <Test>
          <Attributes>
                <Name>Sian</Name>
                <Type>th</Type>
                               <ASIN>12334</ASIN>
          </Attributes>
        </Test>
        <Test>
          <Attributes>
                <Name>JIM</Name>
                <Type>th</Type>
                        <ASIN>54321</ASIN>
          </Attributes>
        </Test>
</Tests>

but im getting
<Tests>
        <Test>
          <Attributes>
                <Name>Sian</Name>
                <Type>th</Type>
                               <ASIN>12334</ASIN>
          </Attributes>
        </Test>
        <Test>
          <Attributes>
                <Name>JIM</Name>
                <Type>th</Type>
                        <ASIN>12334</ASIN>
          </Attributes>
        </Test>
</Tests>

You can see that the ASIN is copying the first one in the iteration each time, and not the correct one for example Jims ASIN wich is 54321!!

Please help me.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>