IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  deleting documents using X-Query

    Posted Thu January 08, 2004 12:30 PM

    Hi

    I am developing a system where I need to have always X documents in a collection. Everytime I will insert new data, it will be as a new document. Thus I need to delete a document and insert the new one. How can I construct the XQuery to remove the oldest document to get X-1 docs before inserting the new document? Till now I managed to delete all the documents having a path /x/y from a specified collection as follows:

    update for $doc in input()
    where $doc/x/y
    do delete $doc

    However, I did not find a way to limit the deletion to the oldest one.

    Brian


    #webMethods
    #API-Management
    #Tamino


  • 2.  RE: deleting documents using X-Query

    Posted Thu January 08, 2004 01:07 PM

    Hi Brian,

    I do not have a solution but a hint: use tf:containsText (see docu). It gives you the date and time of the last modification of any document.

    In a query something like

    declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
    for $p …

    return


    {tf:getLastModified(xf:root($p))}

    )
    sort by ( . descending)

    (This query returned some data for me with newest first. Handy)

    happy trying,

    Timm


    #webMethods
    #API-Management
    #Tamino


  • 3.  RE: deleting documents using X-Query

    Posted Mon January 26, 2004 06:42 PM



    Hi,

    How do you delete whole documents? If I try an update delete input()/document there is an Exception telling me that the result isn’t wellformed.
    So the question is, how do I delete an document using XQuery?

    bye
    Dirk


    Mail: dirk.kaspar[at]pansoft.de
    Web: www.pansoft.de
    Tel.: +49 (0)721 62532 - 16
    Fax: +49 (0)721 62532 - 44

    PANSOFT GmbH
    Tullastr. 28
    76131 Karlsruhe

    PANSOFT - Open Source of course!

    Wollen Sie mehr


    #API-Management
    #Tamino
    #webMethods


  • 4.  RE: deleting documents using X-Query

    Posted Tue January 27, 2004 09:37 AM

    Hello Dirk,

    Using XQuery-Update must result in a wellformed document – so deleting the entire document cannot be done using XQuery. To delete entire documents use the _delete command with a valid XPath, e.g.

    _delete=document

    rather than

    _xquery=update delete input()/document

    Hope this helps.

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


    #Tamino
    #webMethods
    #API-Management


  • 5.  RE: deleting documents using X-Query

    Posted Tue January 27, 2004 10:07 AM

    Hi Stuart,

    Thanks for your quick answer. But I’ve got an other problem with the delete:
    I’d like to delete all Documents with an Datefield older than an given Date. In an Xquery I could formulate an query for that like

    declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"<BR>ceservice/jaxb/persistenceobjects"
    declare namespace xs = “XML Schema
    for $q in input()/document[@letzteaenderung < xs:dateTime(“2003-10-29T10:31:30.030+01:00”)]
    return {$q}

    But how could I express the Date in an XPath?

    Bye
    Dirk


    Mail: dirk.kaspar[at]pansoft.de
    Web: www.pansoft.de
    Tel.: +49 (0)721 62532 - 16
    Fax: +49 (0)721 62532 - 44

    PANSOFT GmbH
    Tullastr. 28
    76131 Karlsruhe

    PANSOFT - Open Source of course!

    Wollen Sie mehr


    #webMethods
    #API-Management
    #Tamino


  • 6.  RE: deleting documents using X-Query

    Posted Tue January 27, 2004 11:12 AM

    Hello Dirk,

    With X-Query (required for _delete) you cannot search using last modified date. So the described scenario can only be done programmatically, for example using the Tamino Java API.

    HTH.

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


    #API-Management
    #Tamino
    #webMethods


  • 7.  RE: deleting documents using X-Query

    Posted Tue January 27, 2004 01:39 PM

    OK, Thanks for your Help.

    I’ve found an solution thats working for me :slight_smile:

    Bye
    Dirk


    Mail: dirk.kaspar[at]pansoft.de
    Web: www.pansoft.de
    Tel.: +49 (0)721 62532 - 16
    Fax: +49 (0)721 62532 - 44

    PANSOFT GmbH
    Tullastr. 28
    76131 Karlsruhe

    PANSOFT - Open Source of course!

    Wollen Sie mehr


    #API-Management
    #Tamino
    #webMethods