当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema complexContent 元素
The complexContent element defines extensions or restrictions on a complex type that contains mixed content or elements only.
complexContent元素的作用是:在包含混合内容和元素的复合类型(complex type)上定义扩展或限制。
<complexContent id=ID mixed=true|false any attributes > (annotation?,(restriction|extension)) </complexContent> |
(The ? sign declares that the element can occur zero or one time inside the complexContent element)
“?”符号用于声明元素在complexContent元素中可以出现的次数(0次或1次)
属性 | 描述 |
---|---|
id | Optional. Specifies a unique ID for the element 可选参数。为元素指定一个独立的ID |
mixed | Optional. Specifies whether character data is allowed to appear between the child elements of this complexType element. Default is false 可选参数。指定是否允许字符数据在complexType类型元素的子元素中出现。默认值为false[假]。 |
any attributes | Optional. Specifies any other attributes with non-schema namespace 可选参数。指定非schema命名空间的其它属性 |
The following example has a complex type, "fullpersoninfo", that derives from another complex type, "personinfo", by extending the inherited type with three additional elements (address, city and country):
下面的案例中包含一个符合类型“fullpersoninfo”,它源于另外一个符合类型“personinfo”,通过扩展了另外三个元素(address、city、country)的继承类型:
<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> |
In the example above the "employee" element must contain, in sequence, the following elements: "firstname", "lastname", "address", "city", and "country".
在上述案例中,“employee”元素必须按顺序包含下列元素:"firstname"、"lastname"、"address"、"city"和"country"。