New Tamino functionality EX

I need an example of code of the new functionality of Tamino 4.1, like partial update(or delete).
Who can help me?
Best,
@nto

Hello @nto,

here is an example of updating part of a document:

   String URI = "http://localhost/tamino/test";
   TConnection conn = TConnectionFactory.getInstance().newConnection(URI);
   TAccessLocation tal = TAccessLocation.newInstance("AccessList");
   TXMLObjectAccessor xmlAccessor = conn.newXMLObjectAccessor(tal,
                                                              TDOMObjectModel.getInstance());

   TXQuery updateQuery = new 
              TXQuery("update replace input()/AccessList/instance[@accesslistID=0]/watcher" +
                      "       with <watcher>has been erased</watcher>");

   TResponse response = xmlAccessor.xquery(updateQuery);



As mentioned by Stuart, the best place to look is in the Tamino documentation on XQuery, which you will probably find somewhere around here: C:\Program Files\Software AG\Tamino\Tamino 4.1.1.1\Documentation\xquery\xq-update.htm

Keep in mind that when changing/deleting parts of documents it is easy to get into the situation that the document no longer conforms to the schema.

I hope that helps,
Trevor.

Trevor,

For single elements the query pattern hat you suggested works fine. But, my requirement is to update/replace multiple elements of a particular doctype.

Any suggestions.
Ravi

Hello Ravi,

if I take the schema from your CDATA posting, the following update query is one way to update multiple nodes with a single query:

   update for $data in input()/SharpStatementData
   let $stmtData := $data/StatementData,
       $stmtKey := $data/KeyRecord
   where $data/StatementID=1
   do (replace $stmtData with <StatementData>New StatementData</StatementData>
       replace $stmtKey  with <KeyRecord>New KeyRecord</KeyRecord>)


How does that look?

Greetings,
Trevor.

Trevor,
That worked fine.

This is the query …(almost the similar one, as you posted)

update for $info in input()/SharpStatementInfo
let $status := $info/Status,
$completeFlag := $info/CompleteFlag
where $info/StatementID=1 and $info/UserID=“admin”
do (replace $status with Generated
replace $completeFlag with N)

Thanks a lot,
Ravi.