Get last update date for a Tamino XML document

Hello!

I still try to monitor a Tamino database(I begin my Tamino adventure almost 2 years ago).

First I’ve tried to use SXS Extensions. I understand that this path was wrong, they couldn’t be used as triggers.

Now I try another solution, a more slow one, I want to periodically scan the database, and find which documents were added, modified and deleted from the database. I have a BIG problem with this solution too, to find if a document was modified I have to make a query for each document, and use getLastModified(). Imagine this for a 10-20.000.000 xmls in the database.

Is there a more elegant solution? Has anybody tried to do something similar? Please share your experience…

Thank you.

Are you able to execute the following XQuery from within the Java API and then process the results?

declare namespace tf=‘http://namespaces.softwareag.com/tamino/TaminoFunction’ for $p in input()/XTest-TelephoneBook/entry, $doc in root($p) return {tf:getInoId($doc)}{tf:getLastModified($doc)}

to experiment with the queries you can use HTTP addressing like so:

http://localhost/tamino/mydb/collection?_xquery=….

Hi!

I’m not sure what you want to say, maybe someone could help and translate that to java…

Of course I can make queries on the Tamino database, the problem is that the document retrieved from query return “” when getLastModified() is called. As I said only when a retrieve a single document the getLastModified() returs the last modified date.

What I was saying is that it is possible to formulate an XQuery that returns a list of getlastmodified values that you could then process. I.e. you don’t have to process each document one at a time. The example I gave was intended to show how to formulate the query. Note that you possibly need an up to date Tamino (4.1.4). But you could try the query using the HTTP interface just to see what happens.

Ok, I understand.

The problem is that I can’t figure out how to construct this query in java, I don’t understand your notation.

Is it possible to use the Tamino Interactive Interface to perform this query?

Below is a XQuery expression that will return ino:id’s and modification dates of documents that have been modified on or after the specified date. I’ve only tested this with Tamino v4.1.4.1.

  
declare namespace tf='http://namespaces.softwareag.com/tamino/TaminoFunction' 
declare namespace xs='http://www.w3.org/2001/XMLSchema'
for $doc in input()/yourdoctype
let $moddate := tf:getLastModified($doc/..),
    $id := tf:getInoId($doc/..),
    $adate := xs:dateTime("2003-06-16T09:50:00Z")
where $moddate >= $adate
return
<match>
<id>{$id}</id>
<date>{$moddate}</date>
</match>



You can try this in the interactive interface.

For coding purposes in Java you need to do the following:-
(1) build up a String with the above XQuery expression;
(2) construct a TXQuery object with the above String;
(3) use the TXMLObjectAccessor interface and use the xquery method.
For more information refer to the Javadoc on the Tamino API for Java.

Hope this clarifies things and what Mark has been suggesting.

Stuart Fyffe-Collins
Software AG (UK) Ltd.

I only have a Tamino v3.1.

The TaminoAPI4J for this version has no TXQuery class!

Anyway I’m interested in a solution that should be used with older versions of Tamino(v2.x, v3.x) also.

For Tamino v3.1.2.1 ( note v2.x is no longer supported so its not worth considering ) you would have to resort to reading every document performing a HTTP HEAD to get the last modified date as a HTTP header. I would recommend upgrading to v4.

best regards,

Stuart Fyffe-Collins
Software AG (UK) Ltd.

I’m just a developer, not a manager… If I must provide a solution for Tamino 2.x and up, thats it… I’ll have to manage that.

But is good to know that v2.x is not supported anymore, so probably I’ll be interested in v3.x and up from now.

For v3.x only v3.1.2.1 is supported, and for this version the only way to solve your problem would be to utilize HTTP HEAD to get the last modified date, and for the bulk of documents you are dealing with it is going to be slow. Thankfully v4 introduces XQuery and you can see that there are functions such as getLastModified() which would be beneficial for you.

The only other suggestion I have for you is as follows:
- change the schema to include a root element attribute called LastModified which is indexed
- change the application that inserts/updates so as to store an appropiate value here.
- then use a Xpath query to query againest this attribute, e.g.:
rootelement[@lastmodified>“somevalue”]/@lastmodified (which means the lastmodified attribute is returned not the whole document.

This method would mean a change to the schema(s), application but the benefit would be that this would work regardless of version ( even v.2 :wink: )

Hope this helps.

Stuart Fyffe-Collins
Software AG (UK) Ltd.