XML Schema complexContent 要素

定義と用法

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

要素情報

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

オプション。annotation

必須オプション。以下のうち1つで構成される:restriction (complexContent) または extension (complexContent)。

文法

<complexContent
id=ID
mixed=true|false
任意の属性
>
(annotation?,(restriction|extension))
</complexContent>

(? 符号で宣言された要素は、complexContent 要素内で0回または1回出現できます。)

属性 説明
id 任意。この要素のユニークな ID を指定します。
mixed 任意。この complexType 要素の子要素間に文字データを出現させるかどうかを指定します。デフォルト値は false です。
任意の属性 任意。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」。