XML Schema schema element
Definition and usage
The schema element defines the root element of the schema.
Element information
Number of occurrences | Once |
Parent element | (no parent element) |
Content | include, import, annotation, redefine, attribute, attributeGroup, element, group, notation, simpleType, complexType |
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>
attributes
id
Optional. Specifies the unique ID of the element.
attributeFormDefault
Optional. The form of the attribute 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 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 this schema. The 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 element and complexType elements in the target namespace. The block attribute prevents complex types (or elements) with specified derived types from being used to replace inherited complex types (or elements). The value can include #all or a list that is a subset of extension, restriction, or substitution:
- extension - Prevents the use of derived complex types through extension to replace this complex type.
- restriction - Prevents the use of derived complex types through restriction to replace this complex type.
- substitution - Prevents the replacement of elements.
- #all - Prevents all derived complex types from being used to replace this complex type.
finalDefault
Optional. Specifies the default value of the final attribute of element, simpleType, and complexType elements in the target namespace of this architecture. The final attribute prevents the specified derived types from being used to replace element, simpleType, or complexType elements. For element and complexType elements, the value can include #all or a list that is a subset 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.
- 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. A prefix for the namespace can also be assigned. 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 namespace http://www.w3.org/2001/XMLSchema 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>