title: Working With Nested XPath Predicates ... Refined
body: <p>All great answers!  But the question deserves refinement ...</p>
  
  <p>I've got the following sample XML ...</p>
  
  <pre><code>&lt;objects&gt;
      &lt;object objectId="1123" ... /&gt;
      &lt;properties refObjectId="1123" ... /&gt;
      &lt;properties refObjectId="1123" refPropertyId="2311" ... /&gt;
      &lt;properties refObjectId="1123" refPropertyId="4611" ... /&gt;
      &lt;object objectId="2123" ... /&gt;
      &lt;properties refObjectId="2123" refPropertyId="4311" ... /&gt;
      &lt;properties refObjectId="2123" refPropertyId="8611" ... /&gt;
      ....
  &lt;/objects&gt;
  </code></pre>
  
  <p>... and the following XPath query ...</p>
  
  <pre><code>//object[//properties[@refObjectId=@objectId and not(@refPropertyId)]]
  </code></pre>
  
  <p>I thought this query would return all <code>object</code> nodes where there is a <code>properties</code> node that has a <code>refObjectId</code> attribute that equals the <code>objectId</code> attribute of the <code>object</code> node <strong>and no 'refPropertyId' attribute ... namely object 1123 only, not object 2123</strong> ... but it doesn't.  It seems the <code>@objectId</code> in the nested predicate does not refer to the <code>objectId</code> attribute of the <code>object</code> node.</p>
  
  <p>Any ideas?  I know the XML structure isn't nested as you would expect, but there are reasons for this structure.</p>