accessor.update (objInstance)

i have the following xml in AccessList collection in Tamino

<?xml version="1.0" encoding="UTF-8"?>




sip:spdsafm@tfdt.op



my fragment of code is

if (ti.hasNext ())
{

TXMLObject objInstance = ti.next() ; Element elemInstance = (Element)objInstance.getElement () ;

Document doc = elemInstance.getOwnerDocument() ;
Element elemTitle = doc.createElement (“watcher”) ;
Text textTitle = doc.createTextNode (“sip:io@tggin.com”) ;

elemTitle.appendChild (textTitle) ;
elemInstance.appendChild (elemTitle) ;

accessor.update (objInstance) ;
}



where ti is an iterator of Tresponse of the query /AccessList/instance

So the line Element elemInstance = (Element)objInstance.getElement () ; should take the element watcher
but it doesn’t work, infact accessor.update (objInstance) ; gives me the ERROR:

/AccessList/instance
com.softwareag.tamino.db.api.accessor.TUpdateException
Access Failure:
ReturnValue:8814
Code:INOXRE8814
MessageText:Element/attribute name not found
MessageLine:Line 1, Column 1: Element name = instance
at com.softwareag.tamino.db.api.accessor.TAccessFailureVerifier.verifyUpdateResponse(TAccessFailureVerifier.java:49)
at com.softwareag.tamino.db.api.accessor.TXMLObjectAccessorImpl.update(TXMLObjectAccessorImpl.java:150)
at Database.show(Database.java:110)
at Database.main(Database.java:227)
Exception in thread “main”

Any idea?
Brgs
@nto

INOXRE8814

Element/attribute name not found

Explanation
The specified element or attribute is unknown in the Data Map.

Action
Correct the element or attribute name and repeat the request.

If i write the content of objInstance with

objInstance.writeTo(System.out);

I obtain the correct updated document:


sip:spam@tiscali.it
sip:io@tin.itcom.softwareag.tamino.db.api.accessor.TInsertException
Access Failure:
ReturnValue:8814
Code:INOXRE8814
MessageText:Element/attribute name not found
MessageLine:Line 1, Column 1: Element name = instance
at com.softwareag.tamino.db.api.accessor.TAccessFailureVerifier.verifyInsertResponse(TAccessFailureVerifier.java:40)
at com.softwareag.tamino.db.api.accessor.TXMLObjectAccessorImpl.insert(TXMLObjectAccessorImpl.java:93)
at Database.show(Database.java:115)
at Database.main(Database.java:232)
Exception in thread “main”

I don’t understand “Element/attribute name not found”… the update is correct…
I have no reason to believe that accessor.update (objInstance) fails.

ThX
@nto

I’m sorry but in the second update i have changed
the watcher element:

Assume:
sip:io@tggin.com=sip:io@tin.it

@nto

I think your problem is that you are trying to update the Element “instance” directly, without reference to its parent document “AccessList”.

Tamino currently handles document-level updates natively. If you want to update a Node directly, you need to use NodeLevelUpdate (see FAQ).

Alternatively you can change your program to retrieve the parent “AccessList” document, add the required node and update the entire document.

HTH



You can use NodelLevelUpdate if you use Microsoft Internet Information Server (IIS) as your web gateway to Tamino. You can not use NodeLevelUpdate with Apache.



Cause on Murphy’s law i’m using Apache, so i cannot use NodeLevelUpdate functionality…

HLP PLZ!!!
@nto

If you are using the Tamino API for Java you cannot use the NodeLevelUpdate functionality anyway. Your program logic is essentially correct but as Bill has pointed out the reason for the error is that you are updating at the wrong element level. So you would have to change the query to retrieve complete documents rather than elements.


Stuart Fyffe-Collins
Software AG (UK) Ltd.

I’m trying to query /AccessList (i.e the root element) and then i’ll use getChildren(“children name”), is a correct approach?

BrgS
@nto

org.w3c.dom.Node has a method getChildNodes() that returns a NodeList, and org.w3c.dom.Element has a method getElementsByTagName(String) that also returns a NodeList.

If the only children of “AccessList” are “instance” nodes, I think the two methods should return the same NodeList.

The safer option is probably getElementsByTagName(“instance”).

Comments anyone?

HTH

I try to do: (with correct query=/AccessList)

TXMLObject xmlObject = response.getFirstXMLObject();
Document doc = (Document) xmlObject.getDocument();
myTransaction = connection.useLocalTransactionMode();

xmlObject.getElement();

NodeList List = doc.getElementsByTagName(“instance”);
but it doesn’t work.
I see in the example InsertConstraintCheck it seems that getElementByTagName is a method of the class Document, not Element.
What about my way to proceed?
BrG @nto

Forget in the previous post the line:
xmlObject.getElement();

there isn’t in my file.
Sorry.
@nto

The method getElementsByTagName() belongs to both Document and Element so you can take your pick.

What do you mean when you say it doesn’t work? Does it throw an exception or just return an empty NodeList?

Can you please post your schema, the xml instance you are processing and your complete code (preferably as an attachment)?

i think it’s an import problem.

C:\JAVA\Database2.java:82: cannot resolve symbol
symbol : variable myTransaction
location: class Database2
myTransaction = connection.useLocalTransactionMode();
^
C:\JAVA\Database2.java:86: cannot resolve symbol
symbol : class NodeList
location: class Database2
NodeList List = doc.getElementsByTagName(“instance”);
^
C:\JAVA\Database2.java:86: cannot resolve symbol
symbol : method getElementsByTagName (java.lang.String)
location: class org.jdom.Document
NodeList List = doc.getElementsByTagName(“instance”);

My import are:
import com.softwareag.tamino.db.api.accessor.;
import com.softwareag.tamino.db.api.common.
;
import com.softwareag.tamino.db.api.connection.;
import com.softwareag.tamino.db.api.objectModel.
;
//import com.softwareag.tamino.db.api.objectModel.jdom.;
import com.softwareag.tamino.db.api.objectModel.dom.
;
import com.softwareag.tamino.db.api.response.;
import org.jdom.
;
import org.jdom.input.;
import org.jdom.output.
;
import java.io.;
import java.util.
;
//import org.w3c.dom.* ;

import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;

I resolve the first problem with:
TLocalTransaction myTransaction = null;
but the others errors remain.

@nto

My fault - I assumed you were using DOM but you’re using JDOM - I should have asked - sorry.

I haven’t used JDOM but from the API documentation I think you need to use getChildren(“instance”), as you suggested, and this will return a java.util.List of Elements.

HTH

Many thanks for the patience.
I’m a little bit confused about DOM and JDOM and i make confusion with their methods.
Where i can find a good resource for a good explanation about these methods?
BrG
@nto

You can find online documentation for JDOM here and for DOM(2) here and you will probably want to download your own copy from these sites too.

HTH