XML Schema 参考手册 完整 XML Schema 参考手册 The schema element defines the root element of the schema. 父元素: (no parent element) Attribute Description Id Optional. Specifies the unique ID of the element. AttributeFormDefault Optional. The form of the attribute declared in the target namespace of the schema. The value must be one of the following strings: “qualified” or “unqualified”. The default is “unqualified”. “unqualified” indicates that attributes of the target namespace do not need to be qualified by a namespace prefix. “qualified” indicates that the attributes of the target namespace must be qualified with a namespace prefix. ElementFormDefault Optional. The form of the element declared in the target namespace of the schema. The value must be one of the following strings: “qualified” or “unqualified”. The default is “unqualified”. “unqualified” indicates that the elements of the target namespace do not need to be qualified by a namespace prefix. “qualified” indicates that the elements of the target namespace must be qualified with a namespace prefix. BlockDefault Optional. Specifies the default value of the block attribute on the element and complexType elements in the target namespace. The block attribute prevents complex types (or elements) with a specified derived type from being used instead of inherited complex types (or elements). The value can contain # all or a list that is a subset of extension, restriction, or substitution: Extension-prevents a complex type derived from an extension from being used to replace that complex type. Restriction-prevents a complex type derived by restriction from being used to replace that complex type. Substitution-prevents the replacement of elements. # all-prevents all derived complex types from being used to replace that complex type. FinalDefault Optional. Specifies the default values for the final attribute of the element, simpleType, and complexType elements in the target namespace of the schema. The final attribute prevents the specified derived type of the element, simpleType, or complexType element. For element and complexType elements, the value can contain # all or a list that is a subset of extension or restriction. For simpleType elements, this value can also contain list and union: Extension-by default, elements in this schema cannot be derived by extension. Applies only to element and complexType elements. Restriction-prevents derivation by restriction. List-prevents derivation from lists. Applies only to simpleType elements. Union-prevents derivation by federation. Applies only to simpleType elements. # all-by default, elements in this schema cannot be derived in any way. TargetNamespace A URI reference to the namespace of the schema. You can also assign a prefix to the namespace. If no prefix is assigned, the schema component of the namespace can be used with unqualified references. Version Optional. Specify the version of schema. Xmlns Specifies a URI reference to one or more namespaces used in this schema. If no prefix is assigned, the schema component of the namespace can be used with unrestricted references. Any attributes Optional. Specifies any other attributes with the non-schema namespace. In this example, the schema component (element name, type) in the http://www.w3.org/2001/XMLSchema namespace is unrestricted, while http://www.w3school.com.cn/w3schoolschema (mystring) is restricted by the wsc prefix:Definition and usage ¶
Element information ¶
Grammar ¶
<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>
Example 1 ¶
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="values" type="xs:string">
</xs:schema>
Example 2 ¶
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:wsc="http://www.w3cschool.cc/w3shoolsschema">
<element name="fname" type="wsc:mystring"/>
</schema>