title: XQuery with if condition in for loop
body: <p>I have written xquery to return results in normal way.</p>
  
  <pre><code>let $results := //data:data
  return 
    &lt;result&gt;
    {
      for $i in $results
      return
        &lt;documentInformation&gt;
          &lt;id&gt;{data($i/DATA:ID)}&lt;/id&gt;
          &lt;status&gt;{data($i/@status)}&lt;/status&gt;
          &lt;title&gt;{data($i/data:title)}&lt;/title&gt;
          &lt;displayName&gt;{data($i/DATA:DISPLAYNAME)}&lt;/displayName&gt;
        &lt;/documentInformation&gt;
    }
    &lt;/result&gt;
  </code></pre>
  
  <p>Now, I have to filter out the results <strong>in for loop with some condition</strong> like</p>
  
  <pre><code>(pseudo logic)
  if id = 'abc' and status ="closed"  
  then skip the row
  else add row.
  </code></pre>
  
  <p>I have tried several ways. but could not run the query..</p>