当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML schema 元素
The schema element defines the root element of a schema.
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 | Optional. Specifies a unique ID for the element 可选参数。为元素指定一个独立的ID |
attributeFormDefault | Optional. The form for attributes declared in the target namespace of this schema. The value must be "qualified" or "unqualified". Default is "unqualified". "unqualified" indicates that attributes from the target namespace are not required to be qualified with the namespace prefix. "qualified" indicates that attributes from the target namespace must be qualified with the namespace prefix 可选参数。指定在当前schema元素的目标命名空间中声明的属性格式。这个值必须是“qualified已授权”或“unqualified未授权”。默认值是“未授权”。“未授权”指明了来自于目标命名空间的属性不允许拥有命名空间的前缀资格;“已授权”指明了来自于目标命名空间的属性允许拥有命名空间的前缀资格 |
elementFormDefault | Optional. The form for elements declared in the target namespace of this schema. The value must be "qualified" or "unqualified". Default is "unqualified". "unqualified" indicates that elements from the target namespace are not required to be qualified with the namespace prefix. "qualified" indicates that elements from the target namespace must be qualified with the namespace prefix 可选参数。指定在当前schema元素的目标命名空间中声明的元素格式。这个值必须是“qualified已授权”或“unqualified未授权”。默认值是“未授权”。“未授权”指明了来自于目标命名空间的元素不允许拥有命名空间的前缀资格;“已授权”指明了来自于目标命名空间的元素允许拥有命名空间的前缀资格 |
blockDefault | Optional. Specifies the default value of the block attribute on element and complexType elements in the target namespace. The block attribute prevents a complex type (or element) that has a specified type of derivation from being used in place of this complex type. This value can contain #all or a list that is a subset of extension, restriction, or substitution: 可选参数。指定元素中block属性的默认值以及目标命名空间中的complexType[复合类型]元素。该block属性禁止包含指定到处类型的复合类型(或元素)由于替代当前的复合类型。这个值可以包含#all,或者是extension[扩展类型]、restriction[限制类型]或substitution[替代类型]的列表:
|
finalDefault | Optional. Specifies the default value of the final attribute on element, simpleType, and complexType elements in the target namespace. The final attribute prevents a specified type of derivation of an element, simpleType, or complexType element. For element and complexType elements, this value can contain #all or a list that is a subset of extension or restriction. For simpleType elements, this value can additionally contain list and union: 可选参数。指定目标命名空间中element[元素]、simpleType[简单类型]元素以及complexType[复合类型]元素的final 属性值。final属性禁止指定element[元素]、simpleType[简单类型]元素以及complexType[复合类型]元素的导出类型。这个值可以包含#all、list[列表属性]和union[联合属性],或者是extension[扩展类型]和restriction[限制类型]的子集列表:
|
targetNamespace | Optional. A URI reference of the namespace of this schema 可选参数。指定当前schema命名空间的URI参数 |
version | Optional. Specifies the version of the schema 可选参数。指定schema版本 |
xmlns | A URI reference that specifies one or more namespaces for use in this schema. If no prefix is assigned, the schema components of the namespace can be used with unqualified references 指定一个URI参数,该参数为当前schema元素的使用指定了一个或多个命名空间。如果未指定前缀,那么命名空间的schema组件可以与未授权的参数一起使用 |
any attributes | Optional. Specifies any other attributes with non-schema namespace 可选参数。指定其它的属性(这些属性无schema命名空间) |
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="values" type="xs:string"> </xs:schema> |
In this example, the schema components (element name, type) in the http://www.w3.org/2001/XMLSchema namespace are unqualified and those for http://www.w3schools.com/w3schoolsschema (mystring) are qualified with the wsc prefix:
在这个案例中,schema组件(元素名称、类型)未在http://www.w3.org/2001/XMLSchema namespace中定义,然而这些组件在http://www.w3schools.com/w3schoolsschema (mystring)已获取wsc前缀资格:
<?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsc="http://www.w3schools.com/w3shoolsschema"> <element name="fname" type="wsc:mystring"/> </schema> |