title: XML attribute names and elements in default namespace?
body: <p>How should the following in XML namespace specification be interpreted?</p>
  
  <blockquote>
    <p>A default namespace declaration applies to all unprefixed element names within its scope. Default namespace declarations do not apply directly to attribute names; the interpretation of unprefixed attributes is determined by the element on which they appear.</p>
  </blockquote>
  
  <p>My intuitive understanding is that unprefixed attributes should be interpreted as belonging to the namespace of the element they belong to. However, the following example seems to prove this false:</p>
  
  <p>Schema:</p>
  
  <pre><code>&lt;xs:schema xmlns:myns="http://test.com/xsd/foo" elementFormDefault="qualified" 
             targetNamespace="http://test.com/xsd/foo" version="1.0" 
             xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;xs:attribute name="Id" type="xs:string" /&gt;
      &lt;xs:element name="Foo"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:attribute ref="myns:Id" /&gt;
      &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Example that passes validation:</p>
  
  <pre><code>&lt;a:Foo xmlns:a="http://test.com/xsd/foo" a:Id="123" /&gt;
  </code></pre>
  
  <p>Example that fails validation:</p>
  
  <pre><code>&lt;Foo xmlns="http://test.com/xsd/foo" Id="123" /&gt;
  </code></pre>
  
  <p>What gives?</p>