2009-10-16 4 views
1

현재 minOccurs 제한을 포함하지 않는 복합 유형이 정의되어 있습니다. 이 comlpex 유형을 요소 유형으로 사용할 때마다 요소에 minOccurs 0, 다른 시간 1을 갖기를 원합니다.XSD minOccurs가 포함 된 유형에 따라 달라집니다.

<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> 

이게 가능합니까?

미리 감사드립니다.

답변

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> 
+1

오늘 그룹을 사랑하고 있습니다. 건배 – ng5000

관련 문제