<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <br>
    You are using contains() to test whether a sequence S contains a
    value V. If you read the spec, you'll see that that isn't what
    contains() does - it tests whether a single string has a particular
    substring within it. If you want to test whether the collection of
    books contains one whose title is "Java Web Services", you can
    simply use the "=" operator thus: {$x/books/title = $y} (no need for
    the /text()). But there's something else wrong with your query - it
    returns the whole document if there is a match, and nothing if there
    isn't. If you want to return the &lt;book&gt; element having the
    relevant title, you can write the query as<br>
    <br>
    doc('books.xml')/books/book[title='Java Web Services']<br>
    <br>
    or if you're in love with FLWOR expressions,<br>
    <br>
    for $x in doc('books.xml')/books/book<br>
    where $x/title = 'Java Web Services'<br>
    return $x<br>
    <br>
    Michael Kay<br>
    Saxonica<br>
    <br>
    On 27/10/2010 08:28, Michael Kay wrote:
    <blockquote cite="mid:4CC7D4B9.7070000@saxonica.com" type="cite">
      <meta http-equiv="content-type" content="text/html;
        charset=ISO-8859-1">
      <style type="text/css"><!-- DIV {margin:0px;} --></style> <br>
      Forwarding an off-list reply to the list. (Mohamed, please don't
      go off-list).<br>
      <br>
      MK<br>
      <br>
      -------- Original Message --------
      <table class="moz-email-headers-table" border="0" cellpadding="0"
        cellspacing="0">
        <tbody>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap="nowrap">Subject:
            </th>
            <td>Re : [xquery-talk] about a query which have a contains
              function</td>
          </tr>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap="nowrap">Date: </th>
            <td>Wed, 27 Oct 2010 00:51:47 +0100 (BST)</td>
          </tr>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap="nowrap">From: </th>
            <td>Mohamed kharrat <a moz-do-not-send="true"
                class="moz-txt-link-rfc2396E"
                href="mailto:med_khr@yahoo.fr">&lt;med_khr@yahoo.fr&gt;</a></td>
          </tr>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap="nowrap">To: </th>
            <td>Michael Kay <a moz-do-not-send="true"
                class="moz-txt-link-rfc2396E"
                href="mailto:mike@saxonica.com">&lt;mike@saxonica.com&gt;</a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <style type="text/css"><!-- DIV {margin:0px;} --></style>
      <div style="font-family: arial,helvetica,sans-serif; font-size:
        10pt;">
        <div>well,<br>
          i have this query<br>
          <br>
          let $y:="Java Web Services"<br>
          <br>
          &nbsp;&nbsp;&nbsp; for $x in doc("query/books.xml")<br>
          <br>
          &nbsp;&nbsp;&nbsp; where contains($x/books/book/title/text(),$y)<br>
          <br>
          &nbsp;&nbsp;&nbsp; return $x<br>
          <br>
          it does't return a value, but it return [err:XPTY0004]A
          sequence with more than one item does not match the type
          text()? according to the Sequence Type Matching rules.<br>
          if i write&nbsp;
          <style>.c9Y6TC { color: rgb(0, 0, 255); }</style> &nbsp;&nbsp;&nbsp;&nbsp;<span
            class="c9Y6TC">return</span> $x/books/book/authors/author
          the same thing, it does't work<br>
          it work only if i write&nbsp;&nbsp; return 1&nbsp; , in this case when the
          query find "Java Web Services" it return 1 <br>
          <br>
          thank you<br>
        </div>
        <div style="font-family: arial,helvetica,sans-serif; font-size:
          10pt;"><br>
          <div style="font-family: times new roman,new york,times,serif;
            font-size: 12pt;"><font face="Tahoma" size="2">
              <hr size="1"><b><span style="font-weight: bold;">De :</span></b>
              Michael Kay <a moz-do-not-send="true"
                class="moz-txt-link-rfc2396E"
                href="mailto:mike@saxonica.com">&lt;mike@saxonica.com&gt;</a><br>
              <b><span style="font-weight: bold;">&Agrave; :</span></b> <a
                moz-do-not-send="true" class="moz-txt-link-abbreviated"
                href="mailto:talk@x-query.com">talk@x-query.com</a><br>
              <b><span style="font-weight: bold;">Envoy&eacute; le :</span></b>
              Mar 26 octobre 2010, 23h 29min 26s<br>
              <b><span style="font-weight: bold;">Objet&nbsp;:</span></b> Re:
              [xquery-talk] about contains function<br>
            </font><br>
            On 26/10/2010 21:30, Mohamed kharrat wrote:
            <blockquote type="cite">
              <div style="font-family: arial,helvetica,sans-serif;
                font-size: 10pt; color: rgb(0, 0, 0);">
                <div>Dear sir,<br>
                  i need to use contains function with&nbsp; NUX JAVA API<br>
                  second question<br>
                  i need to query a collection.<br>
                  <br>
                  how to do that.<br>
                  <br>
                  thank you<br>
                </div>
              </div>
              <br>
              <pre><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
<a moz-do-not-send="true" rel="nofollow" class="moz-txt-link-abbreviated" ymailto="mailto:talk@x-query.com" target="_blank" href="mailto:talk@x-query.com">talk@x-query.com</a>
<a moz-do-not-send="true" rel="nofollow" class="moz-txt-link-freetext" target="_blank" href="http://x-query.com/mailman/listinfo/talk">http://x-query.com/mailman/listinfo/talk</a></pre>
            </blockquote>
            It would be useful to know how far you have got, and where
            you got stuck.<br>
            <br>
            Are you able to run queries at all - or is it this specific
            query you are having difficulty with?<br>
            <br>
            Is your problem with the query, or with the Java API?<br>
            <br>
            What did you try, and how did it fail?<br>
            <br>
            We need to know the answers to these questions so we can try
            to explain what to do in terms you are likely to understand.<br>
            <br>
            When people have problems with the contains function it is
            often because they tried to guess what it did instead of
            reading the specification; the behaviour of a function can
            sometimes be guessed from its name, but not always.<br>
            <br>
            Michael Kay<br>
            Saxonica<br>
          </div>
        </div>
      </div>
      <br>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:talk@x-query.com">talk@x-query.com</a>
<a class="moz-txt-link-freetext" href="http://x-query.com/mailman/listinfo/talk">http://x-query.com/mailman/listinfo/talk</a></pre>
    </blockquote>
    <br>
  </body>
</html>