ドキュメント内の複数の要素を定義する XSD スキーマがあります。コレクションであると予想される要素の 2 つのセット。要素の 1 つのセットは、次のように定義されます。
<xsd:element name="Prospects" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ROW" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" type="xdv:guidKey" nillable="false" />
<xsd:element name="Name" minOccurs="0">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xdv:stringLen50">
<xsd:attribute name="origVal" type="xdv:stringLen50" use="optional" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
... more stuff...
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" fixed="Prospects" />
<xsd:attribute name="alias" type="xsd:string" use="required" fixed="Prospects" />
<xsd:attribute name="keys" type="xsd:string" use="required" fixed="ProposalID" />
<xsd:attribute name="codeTableColVal" type="xdv:codeTableColVal" use="optional" />
</xsd:complexType>
要素の他のセットは次のようになります。
<xsd:element name="Employees" minOccurs="0" maxOccurs="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ROW">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" type="xdv:guidKey" nillable="false" />
<xsd:element name="Seq" type="xdv:guidKey" nillable="false" />
<xsd:element name="CompanyName" minOccurs="0">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xdv:stringLen32">
<xsd:attribute name="origVal" type="xdv:stringLen32" use="optional" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
... more stuff...
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" fixed="Employees" />
<xsd:attribute name="alias" type="xsd:string" use="required" fixed="Employees" />
<xsd:attribute name="keys" type="xsd:string" use="required" fixed="OpportunityID,Seq" />
<xsd:attribute name="codeTableColVal" type="xdv:codeTableColVal" use="optional" />
</xsd:complexType>
主な違いは、前者がプロスペクトに対して minOccurs="0" を指定し、最大値が発生しないことです。次に、ROW に対して minOccurs=0 および maxOccurs=unbounded を定義します。
後者の場合、Employees に対して minOccurs=0 および maxOccurs=1 を定義し、ROW に対して minOccurs または maxOccurs を定義しません。
ユーティリティ プログラムを実行するXsd2Code
と、C# コードが生成されます。Prospects については、ROWs コレクション (List() として) を持つ Prospects プロパティが作成されますが、Employees については、ROW プロパティを持つ Employee プロパティが作成されます。コレクション。
私の質問: これのスキーマ ルールは何ですか? 従業員の ROW に maxOccurs が定義されていないため、親の最小値と最大値が適用されますか、それともコレクションである必要がありますか?
コードを作成しているユーティリティが間違っているのか、それとも .xsd ファイルが間違っているのかを判断しようとしています。