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
Expand all | Collapse all

"contains" Function

  • 1.  "contains" Function

    Posted Fri May 03, 2002 10:45 PM

    I am having trouble using the “contains” function to locate a document based on partial content of one of its elements when the element may occur more than once. This happens frequently in a medical data base where symptoms, medications, and other factors have this requirement.

    To illustrate, I have changed your example file, “xmp-data.xml” slightly, removing the and subelements under , leaving just the tag and the surname, as follows:



    TCP/IP Illustrated
    Stevens
    Addison-Wesley
    65.95

    Advanced Programming in the Unix environment
    Stevens
    Addison-Wesley
    45.00

    Data on the Web
    Abiteboul
    Buneman
    Suciu
    Morgan Kaufmann Publishers
    39.95





    The following query:

    {
    for $b in document(“data/xmp-data.xml”)/bib/book
    where contains ($b/author/text(), “Bune”)
    return
    {
    $b/title
    }
    }

    produces the following error message:

    <?xml version="1.0"?>

    <quip:ExecutionError xmlns:quip=“http://namespaces.softwareag.com/tamino/quip/”>

    quip:queryFileC:\DOCUME~1\wstellho\LOCALS~1\Temp\Query23873.tmp
    </quip:queryFile>

    quip:message
    <![CDATA[Error (3,9): wrong type of arguments for function 'contains'[Abiteboul,Buneman,Suciu][Bune]
    ]]>
    </quip:message>

    </quip:ExecutionError>



    I can around get this error by specifying the position of the author’s name, but that isn’t very practical in general:

    {
    for $b in document(“data/xmp-data.xml”)/bib/book
    where contains ($b/author[2]/text(), “Bune”)
    return
    {
    $b/title
    }
    }


    <?xml version="1.0"?>
    <quip:result xmlns:quip=“http://namespaces.softwareag.com/tamino/quip/”>



    Data on the Web


    </quip:result>



    Even this approach wouldn’t work if I hadn’t removed the and subelements and had searched for, say,

    ?contains($b/author/last[2]/text(), “Bune”)

    Thanks.


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: "contains" Function

    Posted Mon May 06, 2002 09:46 AM

    the contains function expects two string
    arguments. In your first query, however as first
    argument a sequence of two text nodes is passed.
    Your second version selects on of the text-nodes
    explicitly and thus satifsfies the argument type
    of the contains function.

    Another way to handle this situation would be
    by using the ‘string-value’ function:

    {
    for $b in document(“data/xmp-data.xml”)/bib/book
    where contains (string-value($b/author), “Bune”)
    return
    {
    $b/title
    }
    }

    This will do what you want, even with last and
    first tags in your data.

    Sven Eric


    #webMethods
    #Tamino
    #API-Management


  • 3.  RE: "contains" Function

    Posted Mon May 06, 2002 05:27 PM

    Thanks. That works fine.


    #webMethods
    #Tamino
    #API-Management