title: XPath expression using idref
body: <p>I am reading about and testing XQuery and like test tools I use BaseX(www.basex.org) and saxon-HE 9.4.0.6N. 
  For the following simple XML file - no schema attached to the sample.xml: </p>
  
  <pre><code>    &lt;rootab&gt;
       &lt;l1&gt;
         &lt;items p="a"&gt;
           &lt;itema x1="10" id="abc"&gt;testa&lt;/itema&gt;
           &lt;itemb x1="10" id="dfe"&gt;testb&lt;/itemb&gt;
           &lt;itemc x1="10" id="jgh"&gt;testc&lt;/itemc&gt;  
         &lt;/items&gt;
       &lt;/l1&gt; 
       &lt;l2&gt;
           &lt;items p="b"&gt;
             &lt;itema x1="10" xidref="abc"&gt;testa&lt;/itema&gt;
             &lt;itemc x1="10" xidref="jgh"&gt;testc&lt;/itemc&gt;  
             &lt;itemd x1="10" xidref="abc"&gt;testA101&lt;/itemd&gt;  
             &lt;iteme x1="10" xidref="jgh"&gt;testB202&lt;/iteme&gt;  
           &lt;/items&gt;
       &lt;/l2&gt; 
  &lt;/rootab&gt;
  </code></pre>
  
  <p>In Basex_GUI if I enter the following XPath expression: <code>//idref("abc")/..</code>
  the result is:                                           <code>&lt;itema x1="10" xidref="abc"&gt;testa&lt;/itema&gt;</code></p>
  
  <p>In BaseX_GUI if I add the simple XQuery expression: </p>
  
  <pre><code>for $x in doc('sample.xml')//idref("abc")/.. 
      return &lt;aaa&gt;{$x}&lt;/aaa&gt;
  </code></pre>
  
  <p>the result is: </p>
  
  <pre><code>&lt;aaa&gt;
    &lt;itema x1="10" xidref="abc"&gt;testa&lt;/itema&gt;
  &lt;/aaa&gt;
  &lt;aaa&gt;
    &lt;itemd x1="10" xidref="abc"&gt;testA101&lt;/itemd&gt;
   &lt;/aaa&gt;
  </code></pre>
  
  <p>q1) Why the XPath expression returned only one node? I expected two...</p>
  
  <p>In Saxon, by using the below xql file: </p>
  
  <pre><code>    &lt;test&gt;
      {
      doc('sample.xml')//idref("abc")/..
      }
     &lt;/test&gt;
  </code></pre>
  
  <p>or the XQuery expression , I receive the same result by running the command <code>query sample.xql</code>: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;test/&gt;
  </code></pre>
  
  <p>q2)what is wrong in my Saxon test ?</p>
  
  <p>thank you in advance for your help!</p>