title: XQuery unable to select attribute
body: <p>For analyzing some data, I am currently trying to select an attribute in XQuery. Unfortunately, for some reason I can't select it. </p>
  
  <p>Considering the example document</p>
  
  <pre><code>&lt;myroot&gt;
   &lt;betweennode&gt;
    &lt;asd name="test"&gt;
     &lt;asdasd/&gt;
    &lt;/asd&gt;
   &lt;/betweennode&gt;
  &lt;/myroot&gt;
  </code></pre>
  
  <p>the XPath <code>/myroot/betweennode/asd/@name</code> regulary returns <code>test</code>, the XQuery</p>
  
  <pre><code>for $x in /myroot/betweennode/asd
  return $x
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>&lt;asd name="test"&gt;
     &lt;asdasd/&gt;
  &lt;/asd&gt;
  </code></pre>
  
  <p>but the XQuery</p>
  
  <pre><code>for $x in /myroot/betweennode/asd
  return $x/@name
  </code></pre>
  
  <p>does not work (it returns 'ERROR - Cannot create an attribute node (name) whose parent is a document node' in <a href="http://www.xpathtester.com/xquery" rel="nofollow">http://www.xpathtester.com/xquery</a> and '[SENR0001] Attributes cannot be serialized:attribute name {"testInitialize"}.' when I use BaseX and doc('mydoc.xml')/myroot/betweennode/asd in the for-statement).</p>
  
  <p>Could anyone give me a hint why this doesn't work, and how selecting all attributes works in XQuery?</p>