私の XSD は Visual Studio 2010 で動作しないため、それを使用して生成しました。私のものと生成されたものの違いは階層ですか? dtype を使用して複合型を呼び出します。なぜそれがうまくいかないのですか?
ビジュアル スタジオのバージョン:
<?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>
個人的には自分のバージョンがきちんとしていると思いますが、この時点でタイプを参照として使用できないというエラーが発生します:
<?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>