<xsd:extension> 元素 (complexContent)
包含对 complexContent 的扩展。
<extension
base = QName
id = ID
{any attributes with non-schema Namespace}...>
Content: (annotation?, ((group | all | choice | sequence)?, ((attribute |
attributeGroup)*, anyAttribute?)))
</extension>
特性
base
complexType 元素的名称。基值必须是限定名 (QName)。
必需。
id
该元素的 ID。 id 值必须属于类型 ID 并且在包含该元素的文档中是唯一的。可选。
元素信息
出现次数 |
一次 |
父元素 |
|
内容 |
annotation、attribute、attributeGroup、anyAttribute、choice、all、sequence、group |
示例
以下示例通过添加一个元素和一个属性扩展已定义的 complexType 元素。
<xs:complexType name="address">
<xs:sequence>
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="USAddress">
<xs:complexContent>
<xs:extension base="address">
<xs:sequence>
<xs:element name="state" type="xs:string" />
</xs:sequence>
<xs:attribute name="country" type="xs:string" fixed="US" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
其他资源
有关更多信息,请参见“W3C XML 架构第 1 部分:结构建议”中的相关部分,网址为:www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all。