Injecting a copy of a value using a xslt

Discussion in 'XML' started by krach.aran@gmail.com, Jul 23, 2007.

  1. Guest

    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
     
    , Jul 23, 2007
    #1
    1. Advertisements

  2. 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
     
    Joseph Kesselman, Jul 23, 2007
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter
    Replies:
    4
    Views:
    5,880
    Steve Richter
    Apr 18, 2005
  2. Replies:
    2
    Views:
    918
    Henry S. Thompson
    Oct 19, 2005
  3. Alex
    Replies:
    2
    Views:
    1,611
  4. s.subbarayan
    Replies:
    4
    Views:
    442
    s.subbarayan
    Apr 7, 2005
  5. Replies:
    26
    Views:
    2,574
    Roland Pibinger
    Sep 1, 2006
  6. Andy Dingley
    Replies:
    3
    Views:
    653
    Martin Honnen
    Mar 27, 2007
  7. Jeffrey Barish

    Problem using copy.copy with my own class

    Jeffrey Barish, Apr 22, 2008, in forum: Python
    Replies:
    7
    Views:
    575
    Jeffrey Barish
    Apr 24, 2008
  8. Replies:
    6
    Views:
    1,359
    Ken Starks
    May 20, 2008
Loading...