Q:

XML Schema xsd forbidding type

since my XSD din't work with Visual Studio 2010, I used it to generate one. The difference between mine and the Generated one is the hierarchy? I uses dtype to call the complexetypes. Why doesn't that work?
Visual Studio Version:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" 
           elementFormDefault="qualified" 
           targetNamespace="top.xsd" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="top">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="child1">
          <xs:complexType>
            <xs:attribute name="attribute1" type="xs:string" />
          </xs:complexType>
        </xs:element>       
        <xs:element name="child2">
          <xs:complexType>
            <xs:attribute name="attribute2" type="xs:string" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

I personaly find my version neat,but comes up with an error that type can not be used as reference at this point:
<?xml version="1.0" encoding="utf-8"?>
  <xs:schema attributeFormDefault="unqualified" 
             elementFormDefault="qualified"
             targetNamespace="top.xsd" 
             xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="top">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="chield1" type="chield1" />
          <xs:element name="chield2" type="chield2" />
        </xs:sequence>
    </xs:element>
    <xs:complexType name="chield1">
      <xs:attribute name="attribute1" type="xs:string" />
    </xs:complexType>
    <xs:complexType name="chield2">
      <xs:attribute name="attribute2" type="xs:string" />
    </xs:complexType>
  </xs:schema>

A:

The first problem is that your schema document is not well-formed.   
Once the missing end-tag for the complex type of 'top' is supplied, the next problem is that you are referring to types named chield1 and chield2 in what is sometimes called the null namespace.  That is, their expanded names do not identify a specific namespace; XSD and many other specs treat the null namespace as if it were simply another namespace which happens not to have a name.
Your schema document, meanwhile, declares two types named chield1 and chield2 in the namespace top.xsd.  (Not a good namespace name, by the way -- namespace names should be absolute URIs, even though for complicated reasons many tools don't enforce this rule.)  Your declarations for elements chield1 and chield2 do not point to these types.  If you want them to do so, the declarations should say something like:
<xs:element name="chield1" 
            type="tns:chield1"
            xmlns:tns="top.xsd" />
<xs:element name="chield2" 
            type="tns:chield2"
            xmlns:tns="top.xsd" />

In practice, of course, the namespace declaration for tns can go on any common ancestor of the element declarations, instead; a common pattern is to put it on the schema element.

