XML Schema
Element
Definition and Usage
The schema element defines the root element of a schema.
Element Information
- Parent Element: (No parent element)
Syntax
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element. |
attributeFormDefault | Optional. The form for attributes declared in the target namespace of this schema. The value must be one of the following strings: "qualified" or "unqualified". The default value is "unqualified". "unqualified" indicates that attributes from the target namespace need not be qualified with the namespace prefix. <br>"qualified" indicates that attributes from the target namespace must be qualified with the namespace prefix. |
elementFormDefault | Optional. The form for elements declared in the target namespace of this schema. The value must be one of the following strings: "qualified" or "unqualified". The default value is "unqualified". "unqualified" indicates that elements from the target namespace need not be qualified with the namespace prefix. <br>"qualified" indicates that elements from the target namespace must be qualified with the namespace prefix. |
blockDefault | Optional. Specifies the default value for the block attribute on element and complexType elements in the target namespace. The block attribute prevents complex types (or elements) of the specified derivation type from being used to substitute the inherited complex type (or element). The value can contain #all or a subset list of extension, restriction, or substitution: extension - Prevents complex types derived by extension from being used to substitute this complex type. <br>restriction - Prevents complex types derived by restriction from being used to substitute this complex type. <br>substitution - Prevents element substitution. <br>#all - Prevents all derived complex types from being used to substitute this complex type. |
finalDefault | Optional. Specifies the default value for the final attribute on element, simpleType, and complexType elements in the target namespace. The final attribute prevents the specified derivation type of element, simpleType, or complexType elements. For element and complexType elements, the value can contain #all or a subset list of extension or restriction. For simpleType elements, the value can also include list and union: extension - By default, elements in this schema cannot be derived by extension. Applies only to element and complexType elements. <br>restriction - Prevents derivation by restriction. <br>list - Prevents derivation by list. Applies only to simpleType elements. <br>union - Prevents derivation by union. Applies only to simpleType elements. <br>#all - By default, elements in this schema cannot be derived by any method. |
targetNamespace | The URI reference of the namespace for this schema. A prefix for this namespace can also be assigned. If no prefix is assigned, the schema components of this namespace can be used with unqualified references. |
version | Optional. Specifies the version of the schema. |
xmlns | Specifies the URI reference of one or more namespaces used in this schema. If no prefix is assigned, the schema components of this namespace can be used with unqualified references. |
any attributes | Optional. Specifies any other attributes with non-schema namespaces. |
Example 1
Example 2
In this example, the schema components (element name, type) in the http://www.w3.org/2001/XMLSchema namespace are unqualified, while those in the http://www.w3school.com.cn/w3schoolschema namespace (mystring) are qualified with the wsc prefix: