how to delete a document in a collection

for example,I add two documents named a.xml and b.xml to a collection named abc,then how can i delete the document named a.xml in abc collection?
Thanks in advance.
Best regards,
gavinzheng

Hi,

XML documents are stored in Tamino in reference of their INO-IDs; and not with the filenames. So to query/delete or updation would use the same to refer to a perticular document within a list of available values:-

public String getDeleteXMLExpression(String collection, int ino_id)

{
String s = “”;

s += “declare namespace ino = ‘http://namespaces.softwareag.com/tamino/response2’”;
s += “declare namespace tf= ‘http://namespaces.softwareag.com/tamino/TaminoFunction’”;
s += “update for $q in input()/” + collection + " where tf:getInoId($q) = " + ino_id;
s += “do (”;
s += “delete $q/…”; /* the “/…” is appended in order to access the root element. /
s += “)”;
return s;
}

However, if you intend to delete/access an nonXMLObject, you can do so by specifying the name of the file (Docname), the following source sample demonstrates the same with the default collection:-

public String getDeleteNonXMLExpression(String docname)

{
String s = “”;

s += “declare namespace ino = ‘http://namespaces.softwareag.com/tamino/response2’”;
s += “declare namespace tf= ‘http://namespaces.softwareag.com/tamino/TaminoFunction’”;
s += "update for $q in input()/ino:etc where tf:getDocname($q) = docname;
s += “do (”;
s += “delete $q/…”; /
the “/…” is appended in order to access the root element. */
s += “)”;
return s;
}


I hope this will resolve your problem if not get back,


thanks,
Sonal.

I think your answer is a little complex,and how can I get ino_id of a document,as we all know,the ino_id is assigned by the Tamino,we can’t specify it’s value.
I think we can delete a document using
TXMLObjectAccessor.delete(TXMLObject) method,for example,
TXMLObjectModel model = TDOMObjectModel.getInstance();
TXMLObject xmlObject = TXMLObject.newInstance(model);
if(this.docName != null) {
xmlObject.setDocname(this.docName);
}
xmlObject.setDoctype(“article”);
TResponse reponse = accessor.delete(xmlObject);
do you agree with it?
by the way,can you tell me how to create index using API for java?
http://tamino.forums.softwareag.com/viewtopic.php?p=3500
Thanks.
Best regards,
Gavinzheng

Hi Gavinzheng,

Well, if the above approach solves your problem then well and good. But if you want to achieve the same using XQuery then, you can go for the approach suggested. INO:IDs are assigned by Tamino when you insert the documents . You can get ino:id from the xmlObject.getId() API and pass it to the function getDeleteXMLExpression(coll, id).

Regarding, creating index using java API, You cannot create it in here, it must be predefined in schema. Put this question in schema tools for futher refrence.


Thanks,

Sonal.