[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problem Copying an element, always getting first in th

Subject: Problem Copying an element, always getting first in the list
From: "Sian Mace" <sianmace@xxxxxxxxxxx>
Date: Tue, 08 Feb 2005 15:52:03 +0000
test 12334
<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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.