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.


#TechXchangePresenter
 View Only
  • 1.  Problem to get correct search results with tf:containsText()

    Posted Thu June 22, 2006 03:36 PM

    I search through an XML file with this query:

    
    declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
    declare namespace ino = "http://namespaces.softwareag.com/tamino/response2"
    for $q in input()/test
    where $q//*[tf:containsText(., "test")]
    return <result>{$q/Title}<ino:id>{tf:getInoId($q)}</ino:id><searchresult>{$q//*[tf:containsText(., "test")]}</searchresult></result>

    As result I expect only the elements, which the searched string “test” contain.

    But as results I get all nodes and elements from the root to the next upper node of the element.

    What’s wrong with the query?

    Example XML-file:

    
    <?xml version="1.0" encoding="UTF-8"?>
    <UseCaseSpec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
    <Title DocID="1234">test</Title>
    <DocInfo CommentsFlag="true" Continued="true" References="true">
    <Template>
    <TempName>String</TempName>
    <TempVersion>0.0</TempVersion>
    </Template>
    <Authors>
    <Author>
    <AuthorName>String</AuthorName>
    <AuthorDept>String</AuthorDept>
    </Author>
    </Authors>
    <Abbreviations>
    <Abbreviation>
    <A_Term>String</A_Term>
    <A_Definition>String</A_Definition>
    </Abbreviation>
    </Abbreviations>
    <References>
    <RefReferences>
    <RefID>String</RefID>
    <RefTitle>String</RefTitle>
    </RefReferences>
    </References>
    <Product>test hallo</Product>
    </DocInfo>
    </UseCaseSpec>

    If I search the string “test” I get “test hallo” as one result an the howle node “DocInfo” with all lower nodes another result.


    #webMethods
    #API-Management
    #Tamino


  • 2.  RE: Problem to get correct search results with tf:containsText()

    Posted Thu June 22, 2006 08:01 PM

    Your example XML does not match the query: the root of the example is “UseCaseSpec”, not “test”.

    Maybe you could post the XSD along with the sample XML that matches your query.


    #API-Management
    #Tamino
    #webMethods


  • 3.  RE: Problem to get correct search results with tf:containsText()

    Posted Fri June 23, 2006 09:41 AM

    Hi,

    please use the following query:

    
    declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
    declare namespace ino = "http://namespaces.softwareag.com/tamino/response2"
    for $q in input()/UseCaseSpec
    where $q//*[tf:containsText(., "test")]
    return <result>{$q/Title}<ino:id>{tf:getInoId($q)}</ino:id><searchresult>{$q//*[tf:containsText(./text(), "test")]}</searchresult></result> 

    Note that tf:contains works on the textual value of an element, which is constructed by recursively concatenating all text children of the element. As a consequence, if an element contains the text searched, all elements containing this element contain the text as well

    Harald


    #API-Management
    #Tamino
    #webMethods


  • 4.  RE: Problem to get correct search results with tf:containsText()

    Posted Fri June 23, 2006 11:09 AM

    Thank you for your fast help. It works fine.


    #webMethods
    #Tamino
    #API-Management