Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Injecting a copy of a value using a xslt

Reply
Thread Tools

Injecting a copy of a value using a xslt

 
 
krach.aran@gmail.com
Guest
Posts: n/a
 
      07-23-2007
I am using a xml with the following structure :

<xml ....>
<mainnode>
<node1>value1<node1>
<node2>
<subnode1>val</subnode1>
</node2>
<node3>value3</node3>
<node4>value4</value4>
</mainnode>

This xml i want to transform to

<xml ....>
<mainnode>
<node1>value1<node1>
<node2>
<subnode1>val</subnode1>
</node2>
<node3>value3</node3>
<NEWNODE>value1</NEWNODE>
<node4>value4</value4>
</mainnode>

where a newnode is created after a specific node (node3), and contains
the value of node1.
I am not a XSLT guru so i'm gonna need some help.
TIA

Otto Beragg

 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      07-23-2007
Start with the XSLT identity transformation (see the spec, or websearch).

Add a template that recognizes the node you want to process differently.
Modify its operation appropriately. In this case, the easiest thing
might be to have that match node3 and have it output your new node after
it does the basic recursive copy.

Retrieve the new node's value by using xsl:select or xsl:value-of with
the appropriate XPath.


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
is dict.copy() a deep copy or a shallow copy Alex Python 2 09-05-2005 07:01 AM
Injecting a value to a byte/word....using bit wise operators... s.subbarayan C Programming 4 04-07-2005 11:15 AM
PLEASE HELP: injecting a wsdl doc into an application amine zejli ASP .Net 1 10-20-2003 04:03 PM



Advertisments