954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XSLT : XML to XML - need help

Lets say i wanted to add a node copyVar on the desired output then get the value of ID from the target XML how can i do that in XSLT? Thanks for the help

target XML:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<customer_account_create>
  <Customer>
    <Name>Bam</Name>
    <ID>1</ID>
    <Lastname>Test01</Lastname>
    <addr>Alabang</addr>	
  </Customer>
</customer_account_create>


desired output :

<?xml version="1.0" encoding="UTF-8"?>
<customer_account_create>
    <Customer>
        <ID>1</ID>
        <Name>Bam</Name>
        <Lastname>Testme</Lastname>
        <addr>NY</addr>
        <strong><em><copyVar>1</copyVar></em></strong>
    </Customer>
</customer_account_create>
neodagzph
Newbie Poster
1 post since Aug 2009
Reputation Points: 10
Solved Threads: 0
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="xml"/>
	<xsl:template match="/">
		<xsl:apply-templates select="customer_account_create"/>
	</xsl:template>
	<xsl:template match="customer_account_create">
		<customer_account_create>
			<xsl:apply-templates select="Customer"/>
		</customer_account_create>
	</xsl:template>

	<xsl:template match="Customer">
		<xsl:copy>
			<xsl:copy-of select="child::*"/>
			<copyvar><xsl:value-of select="ID"/></copyvar>
		</xsl:copy>
	</xsl:template>
</xsl:stylesheet>
xml_looser
Junior Poster
179 posts since Apr 2009
Reputation Points: 16
Solved Threads: 21
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You