Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old June 19th, 2007, 12:34 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replacing tags within xml using xslt

Hi,

I want to convert xml in one format into another xml format shown below

Input xml :

<Name>
   <Name1>
       <Name11>Name11</Name11>
       <Name12>Name12</Name12>
   </Name1>
   <Name1>
       <Name11>Name21</Name11>
       <Name12>Name22</Name12>
   </Name1>
   <Name2>
       <Name1>
           <Name11>Name11</Name11>
           <Name12>Name12overRide</Name12>
      </Name1>
      <Name3>
           <Name31>Name3Override</Name31>
       </Name3>
   </Name2>
 <Name3>
       <Name31>Name3Origional</Name31>
 </Name3>
 <Name3>
       <Name32>Name3Origional</Name32>
 </Name3>
</Name>

Output xml


<Name>
   <Name1>
       <Name11>Name11</Name11>
       <Name12>Name12overRide</Name12>
   </Name1>
   <Name1>
       <Name11>Name21</Name11>
       <Name12>Name22</Name12>
   </Name1>
   <Name2>
   </Name2>
 <Name3>
           <Name31>Name3Override</Name31>
 </Name3>
 <Name3>
       <Name32>Name3Origional</Name32>
 </Name3>
</Name>

Basically, Name2 tags stores Overriden information for the tag which are already present inside Name root tag.
i want generic template which does this replacing node based on pre - comparision.
i just know like Name2 is the only tag which stores overRiding information for Node's child tag.
Scenario :
1. While replacing \\Name\Name1 tag, i just know like i have to compare \\Name\Name2\Name1\Name11 with \\Name\Name1\Name11,
 If this value matches, i need to replace \\Name\Name1 tag with \\Name\Name2\Name1 tag.
 Also only \\Name\Name1 tag which satisfies this condition will replace, all other \\Name\Name1 tags remain same.
2. While replacing \\Name\Name3 , i just know like i have to compare \\Name\Name2\Name3\Name31 with \\Name\Name3\Name31,
 If this value matches, i just have to replace that \\Name\Name3 node with \\Name\Name2\Name3.
3. This replacing this should be cut paste kind of thing, not copy paste.

Please help me to find its solution,

Please Reply.

Thanks,








Similar Threads
Thread Thread Starter Forum Replies Last Post
strip html tags with xslt smiter XSLT 4 June 19th, 2012 08:34 AM
xslt for tags dnandhak XSLT 4 May 23rd, 2008 05:57 AM
add HTML tags via XSLT chopswil2 XSLT 3 November 5th, 2007 09:30 AM
XSLT output with tags trinkets XSLT 22 November 14th, 2006 11:22 AM
XSLT help : Interpretting HTML tags from XML kunal_kishan XSLT 1 June 26th, 2006 05:37 AM





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