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.  How to test element existence in XQuery

    Posted Fri May 02, 2003 10:06 PM

    Hello People

    I am sorry that I have to disturb you with this simple question but how to test element existence in new Tamino XQuery. I am especially interested in FLWOR queries with where clause (since they are better optimized at the moment). I thought the task was easy but Tamino confused me a bit.

    So let’s take two documents:
    1.
    2. IL-96

    I run some queries with this data:

    for $doc in input()/Document[AllProducts or Product=‘IL-96’]
    return $doc
    Result: 1 and 2

    for $doc in input()/Document
    where $doc[AllProducts or Product=‘IL-96’]
    return $doc
    Result: 1 and 2

    for $doc in input()/Document
    where $doc/AllProducts or $doc/Product=‘IL-96’
    return $doc
    Result: only 2

    I wonder may be I understand something wrong. This XQuery can be so difficult under some circumstances. So are all these queries mean the same or have different semantic (especially the last one)?

    By the way the following query returns me document 1!
    for $doc in input()/Document
    where $doc/AllProducts
    return $doc

    Thanks in advance!


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: How to test element existence in XQuery

    Posted Mon May 19, 2003 11:49 AM

    Hello Alexander,
    the 3rd query must also deliver both documents.
    In my v4.1.1 an v4.1.4 it works correctly.
    Please check with the support.

    Best regards
    Walter


    #webMethods
    #API-Management
    #Tamino


  • 3.  RE: How to test element existence in XQuery

    Posted Mon May 19, 2003 04:50 PM

    It only happens if Product element has index.
    I’ve attached my schema.
    sagsis.tsd (1.53 KB)


    #API-Management
    #webMethods
    #Tamino


  • 4.  RE: How to test element existence in XQuery

    Posted Sat June 07, 2003 11:33 AM

    I also need this feature.
    Couple days ago I wrote the following code:

    // xQuery_2_Object can be a query to Attribute or an Element
    public boolean doesObjectExists(String xQuery_2_Object, TXMLObjectAccessor accessor) {

    try {

    TXQuery query = TXQuery.newInstance(xQuery_2_Object);
    TResponse response = accessor.xquery( query );

    return response.hasQueryContent();
    }

    catch (TXQueryException e) {
    JOptionPane.showMessageDialog(this, e, “TXQueryException”, JOptionPane.ERROR_MESSAGE);
    return false;
    }

    }


    #API-Management
    #webMethods
    #Tamino