title: How to check that id references are valid using xPath 1.0?
body: <p>I'm beginner with xml, xsl and xPath. I would like to know how to check that all my refid attributes are valid? </p>
  
  <p>In other words, I would like to have a xPath 1.0 query that returns TRUE if every refid attribute has a matching ID attribute (with same value of course). All products doesn't necessary have the ref node. </p>
  
  <p>For example: if cookie points to bread AND bread points to milk AND milk poists to cookie THEN return TRUE, otherwise FALSE.</p>
  
  <p>I've been trying to solve this and searched web for good example without luck. Help would be greatly appreciated! </p>
  
  <p>Here's my XML:</p>
  
  <pre><code>&lt;shop&gt;
   &lt;product&gt;
      &lt;cookie ID="01"&gt;
      &lt;price&gt;2&lt;/price&gt;
      &lt;/cookie&gt;
      &lt;ref refid="02"/&gt;
   &lt;/product&gt;
  
    &lt;product&gt;
      &lt;bread ID="02"&gt;
      &lt;price&gt;5&lt;/price&gt;
      &lt;/bread&gt;
      &lt;ref refid="03"/&gt;
   &lt;/product&gt;
  
   &lt;product&gt;
     &lt;milk ID="03"&gt;
     &lt;price&gt;2&lt;/price&gt;
     &lt;/milk&gt;
     &lt;ref refid="01"/&gt;
  &lt;/product&gt;
  
  &lt;/shop&gt;
  </code></pre>