Is it possible to delete an entire instance of XML via XQuery.
My XQuery is as follows:
declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction”
update for $i in input()/genericData[name=‘Dummy’]
where tf:getInoId($i) = 2036
do delete $i
----
I get the following message:
<ino:messagetext ino:code=“INOXQE6450”>Update results in non-well-formed document</ino:messagetext>
ino:messagelineAttempt to delete the root element</ino:messageline>
</ino:message>
—
Any immediate help would be greatly appreciated.
Thanks,
Michelle
I believe you have to use the _delete command, i.e.
_delete=genericData[@ino:id=2036]
Hope this helps.
Stuart Fyffe-Collins
Software AG (UK) Ltd.
Thanks for the reply but I thought the _delete only used in X-Query and not XQuery? Is that not so?
Also, using the Java API, a colleague informed me that the TXMLObjectAccessor can be used to perform inserts and deletes.
Thanks again.
Michelle
The TXMLObjectAccessor has delete() and insert() methods but these take an X-Query(based on Xpath) query and a complete document to insert respectively. Only the xquery() method takes an XQuery or XQuery-Update expression. With XQuery-Update the updates effect the current document (in the same respect as node level update) and so you cannot delete the root element.
Hope this helps.
Stuart Fyffe-Collins
Software AG (UK) Ltd.
Hello Everyone,
just a few days ago someone told me how to delete an entire document using an XQuery Update statement (thanks Christine!).
The key thing to know is that you must delete on the document root, not on the root element.
So this expression will delete the document:
declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
update for $i in input()/genericData[name='Dummy']
where tf:getInoId($i) = 2036
do delete $i/..
In this expression $i refers to the root node “genericData” and we need to have the document root - which is the parent node of the root node, so “/…” will get that.
I hope this tip helps!
Trevor.