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.  substring() problem

    Posted Thu May 05, 2005 07:54 PM

    Hello! I am doing text retrieval and encountered the following problem:

    The xml source has the following part:

    
    <TEI.2>
    .......
    <p>
    The Situation of this place which we Call 
    <hi rend="italic">Council Bluff</hi> 
    which is handsom ellevated a Spot well Calculated for a Tradeing establishment
    </p>
    .......
    </TEI.2>

    I used different approaches to retrieve the text “Call Council Bluff” . Xquery 1:

    
    let $keyword := "Call Council Bluff"
    for $d in input()/p//text()
    let $ref := tf:createTextReference($d, $keyword)
    for $refeach in $ref
    return substring($d, $refeach/@ino:start, string-length($keyword))

    From Xquery1 I get empty result, because “Call” and “Council Bluff” are contained in two text nodes and none of the two text nodes contain the keyword.

    Second approach:

     let $keyword := "Call Council Bluff"
    for $d in input()/p
    let $ref := tf:createTextReference($d, $keyword)
    for $refeach in $ref
    return substring($d//text(), $refeach/@ino:start, string-length($keyword))

    From the second query, I got the following error:
    Runtime type exception: sequence occurred where atomic value required.
    I think it is because $d//text() is not atomic. So I tried the last Xquery:

    let $keyword := "Call Council Bluff"
    for $d in input()/p
    let $ref := tf:createTextReference($d, $keyword)
    for $refeach in $ref
    for $a in $d//text()
    return substring($a, $refeach/@ino:start, string-length($keyword))

    Then I get empty result. What shall I do? I have been working on this for two weeks now!! BTW, from the second and third Xquery, I can get the correct reference descriptions (i.e., tf:createTextReference works).

    thanks a lot.


    #Tamino
    #webMethods
    #API-Management


  • 2.  RE: substring() problem

    Posted Fri May 06, 2005 07:19 PM

    problem solved, thanks.


    #webMethods
    #API-Management
    #Tamino


  • 3.  RE: substring() problem

    Posted Mon May 16, 2005 11:58 PM

    There was another problem which solved in the mean time I accidentally marked this as solved. This one is still not solved. Please help!


    #API-Management
    #Tamino
    #webMethods


  • 4.  RE: substring() problem

    Posted Tue May 17, 2005 12:49 PM

    Look in the “XQuery 4 User Guide”->“Text Retrieval”->“Pattern Matching”.


    #webMethods
    #Tamino
    #API-Management


  • 5.  RE: substring() problem

    Posted Thu May 19, 2005 06:00 PM

    But I cannot find solution from “XQuery 4 User Guide”->“Text Retrieval”->“Pattern Matching”. Can anyone help?


    #Tamino
    #webMethods
    #API-Management


  • 6.  RE: substring() problem

    Posted Thu May 19, 2005 06:03 PM

    I was thinking of the function tf:containsNearText.


    #Tamino
    #webMethods
    #API-Management


  • 7.  RE: substring() problem

    Posted Fri May 20, 2005 08:55 PM

    It did not help. Please let me reiterate my problem:

    I have a node ($p) which contains two children nodes ($c1 and $c2). The desired text($keyword) is contained in the two children nodes. Therefore my problem is when I use tf:createTextReference($p, $keyword), it returns the start postion and end position of the desired text reference, but if I use substring($p, reference/start postion, length), I get the error message that $p is not atomic. How can I get along with problem?


    #API-Management
    #Tamino
    #webMethods


  • 8.  RE: substring() problem

    Posted Mon June 06, 2005 02:44 PM

    Hi,

    the following code does the job (in principle, see below). The trick is not to split teh paragraph into text nodes, but view it as a whole:

    let $keyword := “Call Council Bluff”
    for $d in input()/p
    let $ref := tf:createTextReference($d, $keyword)
    for $refeach in $ref
    return substring($d, $refeach/@ino:start, string-length($keyword))

    Caveat: you get more than one text reference for the keyword (one for each word). So you have to discard those where ino:start is less than a previous ino:start+string-length($keyword)

    Regards

    harald


    #API-Management
    #Tamino
    #webMethods