<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="a" type="aType"/>
  <xs:complexType name="bType">
    <xs:sequence>
      <xs:element type="cType" name="c"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="dType">
    <xs:sequence>
      <xs:element type="cType" name="c"/>
    </xs:sequence>
    <xs:attribute ref="baz:a" xmlns:baz="http://baz"/>
  </xs:complexType>
  <xs:complexType name="cType">
    <xs:simpleContent>
      <xs:extension base="xs:QName" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:attribute ref="foo:n" xmlns:foo="http://foo"/>
        <xs:attribute ref="baz:a" xmlns:baz="http://baz"/>
        <xs:attribute ref="foo:r" xmlns:foo="http://foo"/>
        <xs:attribute ref="baz:b" xmlns:baz="http://baz"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="aType">
    <xs:sequence>
      <xs:element type="bType" name="b"/>
      <xs:element type="dType" name="d" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>