Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.