IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Updating a node in Tamino

  • 1.  Updating a node in Tamino

    Posted Fri September 07, 2001 09:12 AM

    Hi

    i want to update a node in tamino my program is like this

    import java.util.;
    import org.w3c.dom.
    ;
    import com.softwareag.tamino.API.dom.;
    import com.docuverse.dom.
    ;

    public class TaminoUpdate {

    public static final void main(String arg) throws Exception {


    TaminoClient tamino=new TaminoClient(“http://flr1-44/tamino/Applese/tam”);
    try {
    tamino.startSession();
    TaminoResult tr = tamino.query(“tam/Tamtest1[TID="125"]”);
    Document doc = tr.getDocument();
    Element ee=tr.getRoot();
    System.out.println(“Element”+ ee);

    // Update

    Element TAddress = (Element)ee.getElementsByTagName(“TAddress”).item(0);
    System.out.println(“TAddress”+ TAddress);
    System.out.println(TAddress.getChildNodes().item(0));
    TAddress.getChildNodes().item(0).setNodeValue(“55”);
    System.out.println(TAddress.getChildNodes().item(0));

    tamino.update(ee);
    tamino.commit(true);
    tamino.endSession();

    /*
    tr = tamino.query(“tam[Tamtest1/TID="125"]”);
    if (tr.getElement() != null ){
    TaminoClient.printTree(tr.getElement());
    }
    else{
    System.out.println(“not found” );
    }*/
    }

    catch(Exception e)
    {
    System.out.println(e.getMessage());
    }


    }
    }

    But the node is not updating the XML Structure is like this

    -
    -
    125
    Wehlmann124

    -
    125
    44
    Deutsche Bank

    Kindly help

    Regards
    krithi


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management


  • 2.  RE: Updating a node in Tamino

    Posted Fri September 07, 2001 09:57 AM

    Hi,

    I have not tried your Java coding, but from reading thru it I have the impression that the problem may be within your handling of the TaminoResult object. tr is a collection of the documents resulting from your query, so …

    quote:
    Originally posted by Krithivasan:
    tamino.startSession();
    TaminoResult tr = tamino.query(“tam/Tamtest1[TID="125"]”);
    Document doc = tr.getDocument();
    Element ee=tr.getRoot();


    … this is where I think you’re off by one. I would expect iterating thru the enumeration (Element ee = tr.nextElement()), then you could be sure that you’re working on ONE instance and perform the update on this.
    quote:

    System.out.println(“Element”+ ee);

    // Update

    Element TAddress = (Element)ee.getElementsByTagName(“TAddress”).item(0);
    System.out.println(“TAddress”+ TAddress);
    System.out.println(TAddress.getChildNodes().item(0));
    TAddress.getChildNodes().item(0).setNodeValue(“55”);
    System.out.println(TAddress.getChildNodes().item(0));



    So this update statement will work on the single instance, and not on the return of “getRoot()”-method you’re using currently.
    quote:

    tamino.update(ee);
    tamino.commit(true);
    tamino.endSession();


    Please have also a look at the Tamino Documentation chapter DOM APIs, subchapter JAVA HTTP Client. It will guide you along this path.

    Best regards,

    Andreas


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management