title: XQuery:How to count an element is empty or it does not exist?
body: <p>I have a XML file containing elements with the following structure:</p>
  
  <pre><code>&lt;root&gt;
      &lt;listing&gt;
          &lt;seller_info name="1"/&gt;
          &lt;auction_info&gt;
              &lt;notes&gt;&lt;/notes&gt; 
          &lt;/auction_info&gt;
      &lt;/listing&gt;
      &lt;listing&gt;
          &lt;seller_info name="2"/&gt;
          &lt;auction_info&gt;
              &lt;notes&gt;&lt;/notes&gt; 
          &lt;/auction_info&gt;
      &lt;/listing&gt;
      &lt;listing&gt;
          &lt;seller_info name="3"/&gt;
          &lt;auction_info&gt;
          &lt;/auction_info&gt;
      &lt;/listing&gt;
      &lt;listing&gt;
          &lt;seller_info name="4"/&gt;
          &lt;auction_info&gt;
              &lt;notes&gt;ABC&lt;/notes&gt; 
          &lt;/auction_info&gt;
      &lt;/listing&gt;
      &lt;listing&gt;
          &lt;seller_info name="5"/&gt;
          &lt;auction_info&gt;
              &lt;notes&gt;ABC&lt;/notes&gt;
              &lt;notes&gt;DEF&lt;/notes&gt;
          &lt;/auction_info&gt;
      &lt;/listing&gt;
  </code></pre>
  
  <p>I have to count the number of listing that have no notes,it means element note is empty or it does not exist.If one listing have two notes,the notes must have context.In my example,No.1,2,3 listing is count,the result is 3.I wrote code below:</p>
  
  <pre><code>for $x in //listing
  for $y in $x/auction_info/notes
  where count($y)=0 or (count($y)=1 and string-length($y)=0)
  return 
  count($y//..//../seller_info)
  </code></pre>
  
  <p>it return 1 1 1 0 0.I try to add an sum function but no use.Where is the mistake?Thank you for help.</p>