Taminoclient.Delete() Problem

We have a Schema structure

Catalog(Header,Schema?,Data?)
Data(Product*)

The schema is present in Tamino Collection and stored with Catalog information.

Our requirement states that a user can delete one or more products from the “Data” section of
"Catalog"

(i.e) we want to delete a particular node from the document.

Consider the following is a catlog that exists in Tamino DB,



Buyer1














Buyer2







Now if the user deletes the Product “3” and Product “4” for Catalog ID “Buyer1”.
The catalog in Tamino DB should become



Buyer1












Buyer2







We are using Tamino API’s to deal with deletion (TaminoClient delete(element)). But we were not
able to delete a particular node from the retrieved query.


Our Code snippet is as follws

public void deleteProduct(String productNumber)
{
try {
TaminoClient tamino=new TaminoClient(getTaminoClientURL());
tamino.startSession();
TaminoResult tr = tamino.query(getQuery());
Element element = tr.getNextElement();
NodeList nl = element.getElementsByTagName(“Product”);
for (int i = 0; i < nl.getLength(); i++)
{
Node currItem = nl.item(i);
Element e = (Element)currItem;
if (productNumber.equals((String)e.getElementsByTagName(“ManuPartNumber”).item(0).getFirstChild().getNodeValue()))
{
System.out.println(“Deleting”);
tamino.delete(e);
break;
}
}
tamino.commit(false);
tamino.endSession();
}
catch(TaminoError er) {
System.out.println(er.toString());
}
catch(Exception e)
{ System.out.println(e.toString());
}
}


where,
getTaminoClientURL() - "http://rnpmsxml01/tamino/XRVDB10/Catalog"
getQuery() - “/Catalog[Header/CatalogID~=‘Buyer1’]”

We have made sure that the “for” loop is entered successfully and the Message “Deleting” is
displayed. However, the tamino.delete(e) fails. It says “No Matching Record”. Do you think we are missing something.

Error Message = “No matching DOCUMENT found”
Error Code = 8330.

Thanks

If your record really exits then try
taminoresult(object of TaminoResult)= taminoClient(object of TaminoClient).delete(element,, );

If your record really exits then try
taminoresult(object of TaminoResult)= taminoClient(object of TaminoClient).delete(element,, );
:wink:

Kindly give an example for the above structure
What I have specify for element and doctype

K. S. Kini

from your snippet

TaminoResult tr = tamino.query(getQuery());
Element element = tr.getNextElement();
NodeList nl = element.getElementsByTagName(“Product”);

I infer that the element “Product” is not a document element.

If so .delete can’t delete it. .delete can only delete complete documents and it recognizes the
document by the ino:id

Sorry - didn’t complete my message. I wasn’t try to be unhelpful

In your program you read the complete Catalog instance in to a DOM instance. Locate the product elements you want to delete as you are doing now
but remove the product element from the DOM instance using the DOM removeChild method.
Node that DOM nodeLists are (usually) “live” so that when you remove a node from the list the
length of the node list changes and the nodes following the node your have removed will shift up to replace the gap - so use a while loop and increment the “i” counter only for nodes you DON’T delete.
When you are done write the Catalog instance back using the TaminoClient process method.

In the next major release of Tamino you should be able to delete subnodes in the way you are attempting - It is also possible to do this in the present Tamino version using the NodeLevelUpdate DLL but this only works if your web server is IIS