XMLスキーマのcomplexType要素
定義と使用法
complexType要素が複合型を定義します。 複合型の要素が他の要素および/または属性を含むXML要素です。
要素情報
- 親要素:要素は、再定義、スキーマ
文法
<complexType
id=ID
name=NCName
abstract=true|false
mixed=true|false
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>
(annotation?,(simpleContent|complexContent|((group|all|
choice|sequence)?,((attribute|attributeGroup)*,anyAttribute?))))
</complexType>
id=ID
name=NCName
abstract=true|false
mixed=true|false
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>
(annotation?,(simpleContent|complexContent|((group|all|
choice|sequence)?,((attribute|attributeGroup)*,anyAttribute?))))
</complexType>
(?サインインしてcomplexType要素を宣言し、要素が0回または1回発生する可能性があり、*記号は要素が0回以上発生する可能性があることを宣言します。)
属性 | 描述 |
---|---|
id | 可选。规定该元素的唯一的 ID。 |
name | 可选。规定元素的名称。 |
abstract | 可选。规定在实例文档中是否可以使用复杂类型。如果该值为 true,则元素不能直接使用该复杂类型,而是必须使用从该复杂类型派生的复杂类型。 默认值为 false。 |
mixed | 可选。规定是否允许字符数据出现在该复杂类型的子元素之间。 默认值为 false。
|
block | 可选。防止具有指定派生类型的复杂类型被用来替代该复杂类型。该值可以包含 #all 或者一个列表,该列表是 extension 或 restriction 的子集:
|
final | 可选。防止从该 complexType 元素派生指定的类型。该值可以包含 #all 或者一个列表,该列表是 extension 或 restriction 的子集。
|
any attributes | 可选。规定带有 non-schema 命名空间的任何其他属性。 |
例1
次の例は、「注意」という名前の複合型の要素を持っています。
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
例2
次の例では、複合型」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>
<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>
「FIRSTNAME」、「姓」、「住所」、「都市」と「国」:上記の例では、上記の「従業員」の要素は、順番に次の要素が含まれている必要があります。
完全なXMLスキーマリファレンス