title: XPTY0004 Item expected, sequence found, How to find whether a value is present in a sequence or not using Xquery
body: <blockquote>
  <p>Hi.. I would like to find whether a value is present in a sequence or not ,for example If I have an XML which looks like below</p>
  </blockquote>
  <pre><code>&lt;module&gt;
  &lt;content&gt;
  &lt;customer SC=&quot;25&quot; item=&quot;200&quot;&gt;
  &lt;Number id=&quot;250&quot;&gt;
  &lt;Character Value=&quot;PRE&quot; Evaluate=&quot;1&quot;&gt;
  &lt;count Number=&quot;1&quot; Name=&quot;Sree&quot;&gt;FOR XYZ 1994, 1995, 1996, 1997, 0357, 0376&lt;/count&gt;
  &lt;/Character&gt;
  &lt;Character Value=&quot;EMB&quot;&gt;
  &lt;count Number=&quot;154&quot; Name=&quot;Sree&quot; Evaluate=&quot;1&quot;&gt;FOR XYZ 1995, 1996, 1994, 1997, 0357, 0376&lt;/count&gt;
  &lt;/Character&gt;
  &lt;/Number&gt;
  &lt;/customer&gt;
  &lt;customer SC=&quot;25&quot; item=&quot;200&quot; &gt;
  &lt;Number id=&quot;780&quot; &gt;
  &lt;Character Value=&quot;EMB&quot; Evaluate=&quot;1&quot;&gt;
  &lt;count Number=&quot;1&quot; Name=&quot;Sree&quot;&gt;FOR XYZ 1998, 1995, 1996, 1994, 0357, 0376&lt;/count&gt;
  &lt;/Character&gt;
  &lt;Character Value=&quot;EMB&quot;&gt;
  &lt;count Number=&quot;154&quot; Name=&quot;Sree&quot; Evaluate=&quot;1&quot;&gt;FOR XYZ 0357, 1995, 1996, 1997, 1994, 0376&lt;/count&gt;
  &lt;/Character&gt;
  &lt;/Number&gt;
  &lt;/customer&gt;
  &lt;customer SC=&quot;25&quot; item=&quot;240&quot;&gt;
  &lt;Number id=&quot;666&quot; Value=&quot;123&quot; &gt;
  &lt;Character Value=&quot;EMB&quot;&gt;
  &lt;count Number=&quot;2&quot; Name=&quot;Sree&quot; Evaluate=&quot;1&quot;&gt;FOR XYZ 1995, 1994, 1996, 1997, 0357, 0376&lt;/count&gt;
  &lt;/Character&gt;
  &lt;/Number&gt;
  &lt;/customer&gt;
  &lt;customer SC=&quot;25&quot; item=&quot;280&quot;&gt;
  &lt;Number id=&quot;1994&quot; Value=&quot;1234&quot; &gt;
  &lt;Character Value=&quot;POST&quot;&gt;
  &lt;count Number=&quot;3&quot; Name=&quot;Sree&quot; Evaluate=&quot;1&quot;&gt;FOR XYZ 1994, 1995, 1909, 1997, 0357, 0376&lt;/count&gt;
  &lt;/Character&gt;
  &lt;/Number&gt;
  &lt;/customer&gt;
  &lt;customer SC=&quot;25&quot; item=&quot;300&quot;&gt;
  &lt;Number id=&quot;19956&quot; Value=&quot;1235&quot; &gt;
  &lt;Character Value=&quot;PRE&quot;&gt;
  &lt;count Number=&quot;4&quot; Name=&quot;Sree&quot; Evaluate=&quot;1&quot;&gt;FOR XYZ 1997, 1995, 1996, 1994, 0357, 0376&lt;/count&gt;
  &lt;/Character&gt;
  &lt;/Number&gt;
  &lt;/customer&gt;
  &lt;/content&gt;
  &lt;/module&gt;
  </code></pre>
  <blockquote>
  <p>Please find below xquery</p>
  </blockquote>
  <pre><code>    for  $p in doc(&quot;abc.xml&quot;)//module/content
      let $csns := $p/catalouge
          for $csn in $csns
              let $item := $csn/string(@item)
              let $isns := $csn/Number
              for $isn in $isns
                let $id := $isn/string(@id)
        let $count :=  $isn/Character/data(count)
        let $count_status := contains($count, '1994')
  return $count_status
  </code></pre>
  <blockquote>
  <p>am trying to check whether count tag has a value <strong>1994</strong> (FOR A/C <strong>1994</strong>, 1995, 1996, 1997, 0357, 0376) which returns boolean value
  While running Xquery I have tried with contains function but in vain, I got an error when i ran above Xquery</p>
  </blockquote>
  <p><strong>Error:</strong>
  [XPTY0004] Item expected, sequence found: (&quot;FOR A/C 1994, 1995, 1996, 1997, 0357, 0376&quot;, ...).</p>
  <p>But I need to return a boolean value</p>