私はドキュメント内の複数の要素を定義するXSDスキーマを持っています。コレクションとなる要素の2つのセット。要素の1組のフォローように定義されていますXSDでmaxOccursが指定されていない場合、XML文書の要素の最大数はいくらですか?
<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を無視します。
後者の場合、従業員はminOccurs = 0とmaxOccurs = 1を定義し、行はminOccursまたはmaxOccursを定義しません。
Xsd2Code
ユーティリティプログラムを実行すると、ProspectsのC#コードが生成され、ROWsコレクション(List())を持つProspectsプロパティが作成されますが、EmployeesプロパティでEmployeesプロパティが作成されます。コレクションではなくROWプロパティ。
私の質問:whatsはこのためのスキーマルールですか?従業員のROWには maxOccursが定義されていないため、 親の最小値と最大値が適用されるか、それともコレクションである必要がありますか?
私のコードを作成しているユーティリティが間違っているか、.xsdファイルが間違っているかどうかを確認しようとしています。
あるおかげで、私はちょうどここで非常に似たようなことを読む:http://www.w3.org/TR/xmlschema-0/ – Steve
@スティーブニース。私はw3.orgで仕様を見つけようとしていましたが、W3 Schoolsが最初に見つかったのです。間違いなくw3.orgに従ってください – Yuck