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. Advertising

  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. Advertising

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. amine  zejli
    Replies:
    1
    Views:
    404
    Tom Yates
    Oct 20, 2003
  2. amine  zejli
    Replies:
    0
    Views:
    375
    amine zejli
    Oct 19, 2003
  3. Alex
    Replies:
    2
    Views:
    1,193
  4. s.subbarayan
    Replies:
    4
    Views:
    353
    s.subbarayan
    Apr 7, 2005
  5. Replies:
    26
    Views:
    2,074
    Roland Pibinger
    Sep 1, 2006
Loading...

Share This Page