Updating a node in Tamino

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

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