1

現在minOccursの制限が含まれていない複合型が定義されています。このcomlpexタイプを要素タイプとして使用する場合、要素にminOccurs 0を設定したい場合もあれば、1にしたい場合もあります。

<xsd:complexType name="Identifier"> 
    <xsd:sequence> 
        <xsd:element name="Id" type="xsd:string"/> 
        <xsd:element name="Version" type="xsd:string"/> 
    </xsd:sequence> 
</xsd:complexType> 

<xsd:complexType name="Wibble"> 
    <xsd:sequence> 
        <xsd:element name="Id" type="Identifier"/> <!-- I want all elements of Identifier to be mandatory when used as part of a 'Wibble' -->
    </xsd:sequence> 
</xsd:complexType> 


<xsd:complexType name="Wobble"> 
    <xsd:sequence> 
        <xsd:element name="Id" type="Identifier"/> <!-- I want all elements of Identifier to be optional when used as part of a 'Wobble' -->
    </xsd:sequence> 
</xsd:complexType> 

これは可能ですか?

前もって感謝します。

4

1 に答える 1

1

グループはあなたの友達です、例えば

<xsd:group name="IdentifierGroup">
   <xsd:sequence> 
      <xsd:element name="Id" type="Identifier"/>
   </xsd:sequence>
</xsd:group>

<xsd:complexType name="Wibble"> 
    <xsd:sequence> 
        <xsd:group ref="IdentifierGroup" minOccurs="1"/>
        <!-- more elements for Wibble here -->
    </xsd:sequence> 
</xsd:complexType> 

<xsd:complexType name="Wobble"> 
    <xsd:sequence> 
        <xsd:group ref="IdentifierGroup" minOccurs="0"/>
        <!-- more elements for Wobble here -->
    </xsd:sequence> 
</xsd:complexType> 
于 2009-10-16T15:05:20.167 に答える