title: XQuery return text node if it contains given keyword
body: <p>A test sample of my xml file is shown below:</p>
  
  <p>test.xml</p>
  
  <pre><code>&lt;feed&gt;
    &lt;entry&gt;
      &lt;title&gt;Link ISBN&lt;/title&gt;
      &lt;libx:libapp xmlns:libx="http://libx.org/xml/libx2" /&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;title&gt;Link Something&lt;/title&gt;
      &lt;libx:module xmlns:libx="http://libx.org/xml/libx2" /&gt;
    &lt;/entry&gt;
  &lt;/feed&gt;
  </code></pre>
  
  <p>Now, I want to write an xquery which will find all <code>&lt;entry&gt;</code> elements which have <code>&lt;libx:libapp&gt;</code> as a child. Then, for all such entries return the title if the title contains a given keyword (such as Link). So, in my example xml document the xquery should return "Link ISBN".</p>
  
  <p>My sample xquery is shown below:</p>
  
  <p>samplequery.xq (here doc_name is the xml file shown above and libapp_matchkey is a keyword such as 'Link')</p>
  
  <pre><code>declare namespace libx='http://libx.org/xml/libx2';
  declare variable $doc_name as xs:string external;
  declare variable $libpp_matchkey as xs:string external;
  let $feeds_doc := doc($doc_name)
  
  for $entry in $feeds_doc/feed/entry
     (: test whether entry has libx:libapp child and has "Link" in its title child :)
     where ($entry/libx:libapp and $entry/title/text()[contains(.,$libapp_matchkey)])
      return $entry/title/text()
  </code></pre>
  
  <p>This xquery is returning null instead of the expected result 'Link ISBN'. Why is that?</p>