1

ドキュメント内の複数の要素を定義する 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 ファイルが間違っているのかを判断しようとしています。

4

1 に答える 1

4

が指定されていない場合のデフォルトmaxOccursは、 と同じmaxOccurs = "1"です。

XML Schema Indicatorsから。

出現インジケータは、要素が出現する頻度を定義するために使用されます。

注: すべての "Order" および "Group" インジケーター (any、all、choice、sequence、group name、および group reference) の maxOccurs および minOccurs のデフォルト値は 1 です。

于 2011-12-19T19:55:14.730 に答える