Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move one element down one level

Status
Not open for further replies.

sianmace

Programmer
Jun 8, 2004
14
GB
Hi,

I would like to Move one element down a level, and removing it from its original location, and making another copy further down.

Heres what i have

XML
<ItemSearchResponse xmlns:xsd=" xmlns:xsi=" <OperationRequest xmlns=" <Items xmlns=" <Item>
<ASIN>0747581088</ASIN>
<ItemAttributes>
<Author>J.K. Rowling</Author>
</ItemAttributes>
</Item>
.....


Here is what i would like
................ (the same beginning)
<item>
<itemAttributes>
<asin></asin>
.....
 
Right so here is as far as i have got.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" xmlns:amazon=" xmlns="
<xsl:namespace-alias stylesheet-prefix="amazon" result-prefix="#default"/>

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

<xsl:template match="/ItemSearchResponse/amazon:Items/amazon:Item/amazon:ItemAttributes">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<asin><xsl:value-of select="parent::amazon:ASIN"/></asin>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

so i have all the other elements, and i have entered the item attributes node, and im trying to copy an element from above.

once i have done this, i need to delete the original from the above node.

please help me im stuck
 
Try this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:amazon="[URL unfurl="true"]http://webservices.amazon.com/AWSECommerceService/2005-01-19"[/URL] xmlns="[URL unfurl="true"]http://webservices.amazon.com/AWSECommerceService/2005-01-19">[/URL]
	<xsl:namespace-alias stylesheet-prefix="amazon" result-prefix="#default"/>
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="amazon:ItemAttributes">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
			<asin>
				<xsl:value-of select="../amazon:ASIN"/>
			</asin>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="amazon:ASIN"/>
</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top