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.