title: Replace function says item expected sequence found
body: <p>I have the source XML like below, I am extracting title text with all the subelements string except "unwantedtag" content using except function. When I try to add the dot at the end of the title using the replace function. I am getting an error says item expected sequence found. Can anyone help me why I am getting this error and how to solve this:</p>
  
  <p>Sample XML:</p>
  
  <pre><code>&lt;test&gt;
  &lt;title&gt;sample &lt;i&gt;title&lt;/i&gt;&lt;sup&gt;*&lt;/sup&gt; 
      &lt;unwantedcontent&gt;
          &lt;p&gt;unwanted text.&lt;/p&gt;
      &lt;/unwantedcontent&gt;
  &lt;/title&gt;
  &lt;p2&gt;sampletest2&lt;/p2&gt;
  &lt;/test&gt;
  </code></pre>
  
  <p>Xquery:</p>
  
  <pre><code> for $k in (test/*:title)
   let $s1:= $k//text() except (.//*:unwantedcontent)//text()
   let $s2 := replace($s1, "(.*)([^.])$", "$1$2.")
   return $s2
  </code></pre>