Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 12th, 2012, 02:42 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2007
Location: , , .
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to copy new element at child level

Hi,

Following is my XML
<Customer_Details>
<Name_Info>
<Name>temp1</Name>
</Name_Info>
<Name_Info>
<Name>temp2</Name>
</Name_Info>
<Name_Info>
<Name>temp3</Name>
</Name_Info>
</Customer_Details>

Using my application I have searched the Last name from Database of each customer and now using XSL i have to copy it under respective Name_Info node. but when i am trying to copy it is copying Last name at only firt Name_Info node.

Following is my XSL

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="context">
<xsl:for-each select="Customer_Details/Name_info">
<LastName>
<xsl:value-of select="Customer_Info/LastName"/>
</LastName>
</xsl:for-each>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>





Desired OutPut
<Customer_Details>
<Name_Info>
<Name>temp1</Name>
<LastName>lastname1<LastName>
</Name_Info>
<Name_Info>
<Name>temp2</Name>
<LastName>lastname2<LastName>
</Name_Info>
<Name_Info>
<Name>temp3</Name>
<LastName>lastname3<LastName>
</Name_Info>
</Customer_Details>



Thanks
Dishant
  #2 (permalink)  
Old January 13th, 2012, 03:24 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Please show a minimal input XML
__________________
Rummy


Similar Threads
Thread Thread Starter Forum Replies Last Post
<a> element in within block-level elements? steddie1 BOOK: Beginning Web Programming with HTML, XHTML, and CSS, 2nd Edition ISBN: 978-0-470-25931-3 2 March 3rd, 2009 04:43 AM
not able to print child nodes upto 2 level eruditionist XSLT 3 October 30th, 2008 01:10 PM
How to detect the level of an element aliov_85 XSLT 3 April 21st, 2008 01:11 AM
Finding the first child element humansky XSLT 5 April 17th, 2008 08:46 AM
child element kgoldvas XML 4 April 27th, 2006 01:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.