XML Schema complexContent 要素

定義と使用法

complexContent 要素は、複雑な型(混合内容を含むまたは要素のみを含む)の拡張または制限を定義します。

要素情報

出現回数 一度
親要素 complexType
内容

オプション項。annotation

必須項。以下の要素が1つのみ存在する必要があります:restriction (complexContent) または extension (complexContent)。

文法

<complexContent
id=ID
mixed=true|false
any attributes
>
(annotation?,(restriction|extension))
</complexContent>

(? シンボルは complexContent 要素内で0回または1回出現できます。)

属性 説明
id オプション。この要素のユニークな ID を指定します。
mixed オプション。この complexType 要素の子要素間に文字データが出现するかどうかを指定します。デフォルト値は false です。
any attributes オプション。non-schema ナミング空間を持つ他の属性を指定します。

以下の例では、複雑な型「fullpersoninfo」があり、この複雑な型は、3つの追加の要素を使用して継承された型から派生した「personinfo」型を拡張しています:

<xs:element name="employee" type="fullpersoninfo"/>
<xs:complexType name="personinfo">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
  <xs:complexContent>
    <xs:extension base="personinfo">
      <xs:sequence>
        <xs:element name="address" type="xs:string"/>
        <xs:element name="city" type="xs:string"/>
        <xs:element name="country" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

前の例では、「employee」要素は以下の要素を順序で含む必要があります:「firstname」、「lastname」、「address」、「city」および「country」。