XML Schema schema element
Definition and usage
The schema element defines the root element of the schema.
Element information
occurrence | once |
Parent element | (no parent element) |
Content | include, import, annotation, redefine, attribute, attributeGroup, element, group, notation, simpleType, complexType |
Syntax
<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>
Attributes
id
Optional. Specifies the unique ID of the element.
attributeFormDefault
Optional. The form of the attribute declared in the target namespace of the schema. This value must be one of the following strings: "qualified" or "unqualified". The default value is "unqualified".
- "unqualified" indicates that attributes in the target namespace do not need to be qualified with a namespace prefix.
- "qualified" indicates that attributes in 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. This value must be one of the following strings: "qualified" or "unqualified". The default value is "unqualified".
- "unqualified" indicates that elements in the target namespace do not need to be qualified with a namespace prefix.
- "qualified" indicates that elements in 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 specified derived types from replacing inherited complex types (or elements). This value can include #all or a list, which is a subset of extension, restriction, or substitution:
- extension - Prevent the use of derived complex types to replace the complex type through extension.
- restriction - Prevent the use of derived complex types to replace the complex type through restriction.
- substitution - Prevent element substitution.
- #all - Prevent all derived complex types from replacing the complex type.
finalDefault
Optional. Specifies the default value of the final attribute of element, simpleType, and complexType elements in the target namespace of the schema. The final attribute prevents the specified derived type of element, simpleType, or complexType. For element and complexType elements, the value can contain #all or a list that is a subset of extension or restriction. For simpleType elements, the 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 by list. Applies only to simpleType elements.
- union - Prevents derivation by union. Applies only to simpleType elements.
- #all - By default, elements in this schema cannot be derived by any method.
targetNamespace
The URI reference of the namespace of this schema. You can also assign a prefix to this namespace. If no prefix is assigned, the schema components of this namespace can be used with unrestricted references.
version
Optional. Specifies the version of the schema.
xmlns
Specifies one or more namespace URIs used in this schema. If no prefix is assigned, the schema components of this namespace can be used with unrestricted references.
any attributes
Optional. Specifies any other attributes with a non-schema namespace.
Instance
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
In this example, the schema component (element name, type) in the http://www.w3.org/2001/XMLSchema namespace is unrestricted, while http://www.codew3c.com/codew3cschema (mystring) is restricted by the wsc prefix:
<?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsc="http://www.codew3c.com/codew3cschema" <element name="fname" type="wsc:mystring"/> </schema>