xs:all |
<xs:all id = " ID " maxOccurs = " 1 " minOccurs = "(0 1 )"> <!-- ( xs:annotation?, xs:element* ) --> </xs:all>
The xs:all element indicates that every element represented by one of its child xs:element elements must appear. However, the order of the child elements in the instance element does not matter. For example, an xs:all element can require that each FullName element have exactly one FirstName child and exactly one LastName child, but that the order of the two child elements does not matter; the first name can come first or the last name can come first.
The xs:all element must be the top group in its content model (i.e., an xs:choice or xs:sequence cannot contain an xs:all element). The complete group represented by the xs:all element can occur either zero or one time as indicated by its minOccurs and maxOccurs attributes. By default, it must occur exactly once. Furthermore, the minOccurs and maxOccurs attributes of each of the individual xs:element elements inside the xs:all element must also be set to either 0 or 1. xs:all cannot indicate , for example, that a FullName element must contain between zero and five FirstName s and between one and three LastName s in any order.
xs:annotation |
<xs:annotation id = " ID "> <!-- ( xs:appinfo xs:documentation )* --> </xs:annotation>
The xs:annotation element is ignored by schema validators. Its purpose is to provide metainformation about the schema or schema element in which it appears. Information intended for human readers is placed in xs:documentation child elements. Information intended for software programs is placed in xs:appinfo child elements.
xs:any |
<xs:any id = " ID " maxOccurs = " nonNegativeInteger unbounded" minOccurs = " nonNegativeInteger " namespace = " ##any ##other anyURI * ##targetNamespace? ##local? " processContents = " lax skip strict "> <!-- xs:annotation? --> </xs:any>
The wildcard element xs:any is useful when writing schemas for languages such as XSLT that routinely include markup from multiple vocabularies that are unknown when the schema is written. It indicates that between minOccurs and maxOccurs elements from one or more namespaces identified by the namespace attribute may appear at that position in a content model. As well as literal namespace URIs, the special value ##targetNamespace can be included in the list to indicate that any element from the schema's target namespace can be used. The special value ##local can be included in the list to indicate that elements not in any namespace can be used. Instead of the list of namespace URIs, you can use the special value ##any to indicate that all elements from any namespace or no namespace are allowed, or the special value ##other to indicate that elements from namespaces other than the schema's target namespace can be used.
The processContents attribute indicates whether the elements represented by xs:any have to be declared or whether they can be completely unfamiliar to the schema. It has one of these three values:
Elements represented by this xs:any element must be declared or have an xsi:type attribute. Furthermore, the element must be valid according to its declaration or type.
Elements represented by this xs:any element need not be declared in the schema and need not be valid even if they are declared.
Elements represented by this xs:any element must be validated if they are declared or if they have an xsi:type attribute, but must not be validated if they are neither declared nor have an xsi:type attribute.
The default value is strict .
xs:anyAttribute |
<xs:anyAttribute id = " ID " namespace = " ##any ##other anyURI * ##targetNamespace? ##local?" processContents = "(lax skip strict )" > <!-- (xs:annotation?) --> </xs:anyAttribute>
The xs:anyAttribute element appears inside xs:complexType elements, where it indicates that elements of that type can have any attribute from one or more namespaces. It can also appear inside xs:attributeGroup elements, where it adds attributes from one or more namespaces as potential members of the group. The namespace attribute contains a whitespace-separated list of the namespace URIs that are allowed for this element's attributes. As well as literal namespace URIs, the special value ##targetNamespace can be included in the list to indicate that any attribute from the schema's target namespace can be used. The special value ##local can be included in the list, indicating that attributes not in any namespace (unprefixed attributes) may be used. Instead of the list of namespace URIs, you can use the special value ##any to indicate that all attributes from any namespace are allowed or the special value ##other to indicate that attributes from namespaces other than the schema's target namespace can be used.
The processContents attribute indicates whether the attributes themselves have to be declared, generally as top-level attributes. It has one of these three values:
Attributes represented by this xs:anyAttribute element must be declared, and the attribute must be valid according to its declaration. This is the default.
Attributes represented by this xs:anyAttribute element must be valid if they are declared but must not be validated if they are not declared.
Attributes represented by this xs:anyAttribute element need not be declared in the schema and need not be valid even if they are declared.
xs:appinfo |
<xs:appinfo source = " anyURI "> <!-- any well-formed XML markup --> </xs:appinfo>
The xs:appinfo element appears exclusively inside xs:annotation elements, where it provides machine-readable information about the schema or schema element it's documenting. It has no effect on schema validation. It can contain absolutely any XML markup: an XSLT stylesheet for the schema, a schema for the schema, a schema in a different schema language such as Schematron, or anything else you can imagine. The only restriction is that the contents must be well-formed. Alternately, instead of or in addition to including this information directly, the source attribute can point to it using a URI.
xs:attribute |
<xs:attribute default = " string " fixed = " string " form = "( qualified unqualified ) id = " ID " name = " NCName " ref = " QName " type = " QName " use = "( optional prohibited required )"> <!-- ( xs:annotation?, xs:simpleType? ) --> </xs:attribute>
The xs:attribute element declares an attribute. Inside an xs:complexType element it indicates that elements of that type can have an attribute with the specified name and type.
The default value of the attribute reported for those elements in the instance document that do not contain an explicit specification of this attribute.
A default value for this attribute that may not be overridden in the instance document. An xs:attribute element cannot have both fixed and default attributes.
If this has the value qualified , then the attribute must be in the schema's target namespace. If this has the value unqualified , then the attribute must not be in any namespace. The default value for this is set by the attributeFormDefault attribute on the root xs:schema element.
An XML name unique among all of the ID-type attributes in this schema document.
The local name of the attribute.
The qualified name of an attribute declared by a top-level xs:attribute element elsewhere in the schema. Either the name or ref attribute should be provided, but not both.
The qualified name of the type of the attribute, either a built-in simple type such as xs:integer or a user -defined simple type.
One of the three keywords optional , prohibited , or required which have the following meanings:
Authors of instance documents may or may not include this attribute as they choose. This is the default.
Authors of instance documents must not include this attribute. This is typically used to remove legal attribute values when defining a subtype that would otherwise inherit an attribute declaration from its base type.
Authors of instance documents must include this attribute on all elements of the requisite type.
The xs:attribute element may contain a single xs:annotation element to describe itself. This has no effect on the attribute type.
In place of a type attribute, the xs:attribute element may contain a single xs:simpleType element that provides an anonymous type for the attribute derived from a base simple type.
xs:attributeGroup |
<xs:attributeGroup id = " ID " name = " NCName " ref = " QName "> <!-- ( xs:annotation?, (xs:attribute xs:attributeGroup)*, xs:anyAttribute? ) --> </xs:attributeGroup>
The xs:attributeGroup element is used in two ways. At the top level of the schema, it has a name attribute and defines a new attribute group. The attributes in the group are indicated by the child elements of the xs:attributeGroup element. Inside an xs:complexType element or another xs:attributeGroup , it has a ref attribute but no name and adds the attributes in the referenced group to the type or group's list of attributes.
xs:choice |
<xs:choice id = " ID " maxOccurs = "( nonNegativeInteger unbounded )" minOccurs = " nonNegativeInteger "> <!-- ( xs:annotation?, (xs:element xs:group xs:choice xs:sequence xs:any)*) --> </xs:choice>
The xs:choice element indicates that any element or group represented by one of its child elements may appear at that position in the instance document. At the least, minOccurs elements from the choice must appear. At most, maxOccurs elements from the choice must appear. The default for both minOccurs and maxOccurs is 1.
xs:complexContent |
<xs:complexContent id = " ID " mixed = "( true false )"> <!-- ( xs:annotation?, (xs:restriction xs:extension) ) --> </xs:complexContent>
The xs:complexContent element is used inside xs:complexType elements to derive a new complex type from an existing complex type by restriction or extension. When deriving by extension, the mixed attribute must have the same value as the base type's mixed attribute. When deriving by restriction, the mixed attribute can have the value false to disallow mixed content that would be allowed in the base type. It can have the value true only if the base type allows mixed content. In other words, a derived type can disallow mixed content that's allowed in the base type, but cannot allow it if the base type doesn't already allow it.
xs:complexType |
<xs:complexType abstract = "( true false )" block = "( #all extension restriction )" final = "( #all extension restriction )" id = " ID " mixed = "( true false )" name = " NCName " > <!-- ( xs:annotation?, (xs:simpleContent xs:complexContent ((xs:group xs:all xs:choice xs:sequence)?, ((xs:attribute xs:attributeGroup)*, xs:anyAttribute?)))) --> </xs:complexType>
The xs:complexType element defines a new complex type, that is, an element type that can potentially contain child elements, attributes, or both. The valid child elements and attributes for elements of this type are specified by the contents of the xs:complexType element. The mixed attribute specifies whether the complex type is allowed to contain text interspersed with its child elements. If the xs:complexType element is a top-level element, then it has a name attribute and defines a named type. Otherwise, if the xs:complexType element appears inside an xs:element element, then it does not have a name attribute and defines an anonymous type for that element alone.
If the abstract attribute has the value true , then no elements of this type can be included in instance documentsonly elements of subtypes derived from this type, which are marked as elements of the subtype by an xsi:type attribute, can be included. If the final attribute has the value restriction , then this type cannot be subtyped by restriction. If the final attribute has the value extension , then this type cannot be subtyped by extension. If the final attribute has the value #all , then this type cannot be subtyped by either restriction or extension. The default value of the final attribute is set by the finalDefault attribute on the root xs:schema element. If the block attribute has the value extension or restriction , then instances of this type cannot be replaced in instance documents by instances of subtypes derived from this type by extension or restriction, respectively, although such subtypes may still be defined and used for other elements. If the block attribute has the value #all , then this type cannot be replaced in instance documents by instances of any subtype. The default value of the block attribute is set by the blockDefault attribute on the root xs:schema element.
xs:documentation |
<xs:documentation source = " anyURI " xml:lang = " language "> <!-- any well-formed XML markup --> </xs:documentation>
The xs:documentation element appears exclusively inside xs:annotation elements, where it provides human-readable information about the schema or schema element it's annotating. It has no effect on schema validation. It can contain absolutely any XML markup: XHTML, DocBook, or just plain text. The only restriction is that the contents must be well-formed. Alternately, instead of or in addition to including this information directly, the source attribute can point to it using a URI. The xml:lang attribute can indicate the language in which the description is written. You could even include multiple xs:documentation elements in different languages.
xs:element |
<xs:element abstract = "( true false )" block = "( #all extension restriction substitution )" default = " string " final = "( #all extension restriction )" fixed = " string " form = "( qualified unqualified )" id = " ID " maxOccurs = "( nonNegativeInteger unbounded )" minOccurs = " nonNegativeInteger " name = " NCName " nillable = "( true false )" ref = " QName " substitutionGroup = " QName " type = " QName "> <!-- ( xs:annotation?, ((xs:simpleType xs:complexType)?, (xs:unique xs:key xs:keyref)*) ) --> </xs:element>
The xs:element element declares an element, including its name and type. Used at the top level of the schema, it indicates a potential root element. Used inside an xs:complexType element, it indicates a potential child element of another element. Alternately, instead of specifying a name and a type, it can have a ref attribute that points to a top-level element declaration elsewhere in the schema.
If the abstract attribute has the value true , then only elements from this element's substitution group are allowed in instance documents, not elements actually declared by this declaration.
default is the default value of the element reported for empty elements matching this declaration in the instance document.
If the block attribute contains the value extension or restriction , then this element cannot be replaced in instance documents by instances of subtypes derived from this element's type by extension or restriction, respectively. If the block attribute has the value substitution , then this element cannot be replaced in instance documents by members of this element's substitution group. If the block attribute has the value #all , then this element cannot be replaced in instance documents by subtype instances or substitution group members.
The final attribute controls which elements can refer to this element as the head of their substitution group. If the value contains the keyword restriction , then restrictions of this element's type cannot do so. If the value contains the keyword extension , then extensions of this element's type cannot do so. If the value is #all , then neither extensions nor restrictions of this type can do so.
If the form attribute has the value qualified , then the element is in the schema's target namespace. If it has the value unqualified , then the element is not in any namespace. The default value is set by the elementFormDefault attribute on the root xs:schema element. This attribute can only be used on locally declared elements. All globally declared elements are always in the schema's target namespace.
id is an XML name unique within ID-type attributes in this schema document.
This signifies the maximum number of times this element may be repeated in valid instance documents.
This signifies the minimum number of times this element must be repeated in valid instance documents.
This contains the required name of the element. If this is omitted, the xs:element should be empty and must have a ref attribute that points to another element declaration.
If nillable has the value true , then this element can be specified as being "nil" using an xsi:nil="true " attribute in the instance document.
The qualified name of an element declared by a top-level xs:element element.
This is the qualified name of a globally declared element for which this element may substitute in instance documents.
This is the qualified name of the type of the element, either a built-in simple type such as xs:integer , xs:anyType , or a user-defined type.
The xs:element element may contain an optional xs:annotation . If and only if the xs:element element does not have a type attribute, then it must have either an xs:simpleType child element or an xs:complexType child element that provides an anonymous type for this element. Finally, it may have any number of xs:key , xs:keyref , and xs:unique elements that set uniqueness and identity constraints.
xs:enumeration |
<xs:enumeration id = " ID " value = " anySimpleType "> <!-- (xs:annotation?) --> </xs:enumeration>
The xs:enumeration facet element is used inside xs:restriction elements to derive new simple types by listing all valid values. The value attribute contains a single valid value of the type specified by the parent xs:restriction 's base attribute. This xs:restriction element contains one xs:enumeration child element for each valid value.
xs:extension |
<xs:extension base = " QName " id = " ID "> <!-- (xs:annotation?, ((xs:group xs:all xs:choice xs:sequence)?, ((xs:attribute xs:attributeGroup)*, xs:anyAttribute?))) --> </xs:extension>
The xs:extension element is used inside xs:simpleContent and xs:complexContent elements to derive a new complex type that adds attributes and/or child elements not present in the base type. The base type being extended is given by the value of the base attribute. The child elements and attributes added to the base type's content model are specified by the content of the xs:extension element. An instance of such an extended type must have all the child elements required by the base type followed by all the child elements required in the xs:extension .
xs:field |
<xs:field id = " ID " xpath = " XPath expression "> <!-- (xs:annotation?) --> </xs:field>
One or more xs:field elements are placed inside each xs:unique , xs:key , and xs:keyref element to define a value calculated by the XPath expression in the xpath attribute. The context node for this expression is set in turn to each element in the node set selected by the xs:selector element.
Not all XPath expressions are allowed here. In particular, the XPath expression must limit itself to the child axis, except for the last step, which may use the attribute axis. The only node tests used are name tests (element and attribute names , the * wildcard, and the prefix :* wildcard). Abbreviated syntax must be used, and predicates are not allowed. Thus, person/name/first_name/@id is a legal XPath expression for this attribute, but person//name/@id is not. Several instances of this restricted form of XPath expression can be combined with the vertical bar so that person/name/first_name/@id person/name/last_name/@id is also an acceptable XPath expression. Finally, the XPath expression may begin with .// so that .//name/@id is legal. However, this is the only place the descendant-or-self axis can be used. No other forms of XPath expression are allowed here.
xs:fractionDigits |
<xs:fractionDigits fixed = "( true false )" id = " ID " value = " nonNegativeInteger " > <!-- (xs:annotation?) --> </xs:fractionDigits>
The xs:fractionDigits facet element is used when deriving from xs:decimal (and its subtypes) by restriction. It limits the number of non-zero digits allowed after the decimal point to, at most, the number specified by the value attribute. This sets only the maximum number of digits after the decimal point. If you want to set the minimum number of digits required, you'll have to use the xs:pattern element instead. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of fractionDigits given here.
xs:group |
<xs:group name = " NCName " ref = " NCName " minOccurs = " nonNegativeInteger " maxOccurs = " nonNegativeInteger unbounded"> <!-- ( xs:annotation?, (xs:all xs:choice xs:sequence) ) --> </xs:group>
The xs:group element can be used in two ways. As a top-level element with a name attribute, it defines a model group that can be referenced from complex types elsewhere in the schema. The content model of the group is established by a child xs:all , xs:choice , or xs:sequence element.
The second use is inside an xs:complexType element. Here, the xs:group element indicates that the contents of the group should appear at this point in the instance document at least as many times as indicated by the minOccurs attribute and at most as many times as indicated by the maxOccurs attribute. The default for both of these is 1. The group to be included is indicated by the ref attribute that contains the name of a top-level xs:group element found elsewhere in the schema.
xs:import |
<xs:import id = " ID " namespace = " anyURI " schemaLocation = " anyURI " > <!-- ( xs:annotation? ) --> </xs:import>
Since each schema document has exactly one target namespace, the top-level xs:import element is needed to create schemas for documents that involve multiple namespaces. The namespace attribute contains the namespace URI for the application that the imported schema describes. If the imported schema describes elements and types in no namespace, then the namespace attribute is omitted. The optional schemaLocation attribute contains a relative or absolute URL pointing to the actual location of the schema document to import.
There is no limit to import depth. Schema A can import schema B, which itself imports schema C and schema D. In such a case, schema A can use definitions and declarations from all four schemas. Even recursion (schema A imports schema B, which imports schema A) is not prohibited. Since the imported schema must describe a different target namespace than the importing schema, conflicts between definitions in the multiple schemas are normally not a problem. However, if conflicts do arise, then the schema is in error and cannot be used. There are no precedence rules for choosing between multiple conflicting definitions or declarations.
xs:include |
<xs:include id = " ID " schemaLocation = " anyURI "> <!-- (annotation?) --> </xs:include>
The top-level xs:include element is used to divide a schema into multiple separate documents. The schemaLocation attribute contains a relative or absolute URI pointing to the schema document to include. It differs from xs:import in that all included files describe the same target namespace.
There is no limit to inclusion depth. Schema A can include schema B, which itself includes schema C and schema D. In such a case, schema A can use definitions and declarations from all four documents. Even recursion (schema A includes schema B, which includes schema A) is not prohibited, although it is strongly discouraged. Instance documents would refer only to the top-level schema A in their xsi:schemaLocation or xsi:noNamespaceSchemaLocation attribute.
Validation is performed after all includes are resolved. If there are any conflicts between the including schema and an included schemafor instance, one schema declares that the FullName element has a simple type, and another declares that the FullName element has a complex typethen the schema is in error and cannot be used. Most of the time, schemas should be carefully managed so that each element and type is defined in exactly one schema document.
xs:key |
<xs:key id = " ID " name = " NCName " > <!-- (xs:annotation?, (xs:selector, xs:field+) ) --> </xs:key>
Keys establish uniqueness and co-occurrence constraints among various nodes in the document. For example, you can define a key for an Employee element based on its EmployeeNumber child element and then require that each Assignment element have a team attribute whose contents are a list of employee keys.
The xs:key element defines a new key. It appears only as a child of an xs:element element following the element's type. The name of the key is specified by the name attribute. The elements that have a value for this key are identified by the xs:selector child element. The value of the key for each of these nodes is given by the xs:field child element and must be unique within that set. If there is more than one xs:field child element, then the key is formed by concatenating the value of each field.
xs:keyref |
<xs:keyref id = " ID " name = " NCName " refer = " QName " > <!-- (xs:annotation?, (xs:selector, xs:field+) ) --> </xs:keyref>
The xs:keyref element is placed inside xs:element elements to require that the element selected by the xs:selector must match an xs:key or xs:unique with the name given by the refer attribute. The key that is referred to must be a child of one of the ancestors of this xs:keyref . The value that is matched against the specified key is determined by the concatenation of the values of the xs:field child elements.
xs:length |
<xs:length fixed = "( true false )" id = " ID " value = " nonNegativeInteger " > <!-- (xs:annotation?) --> </xs:length>
The xs:length facet element specifies the exact number of characters in a type derived from xs:string , xs:QName , xs:anyURI , or xs:NOTATION . When applied to a list type, such as xs:ENTITIES , this facet specifies the number of items in the list. Finally, when applied to xs:hexBinary and xs:base64Binary , it specifies the number of bytes in the decoded data, rather than the number of characters in the encoded data. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of length given here.
xs:list |
<xs:list id = " ID " itemType = " QName " > <!-- (xs:annotation?, (xs:simpleType?) ) --> </xs:list>
The xs:list element is placed inside an xs:simpleType element to derive a new list simple type from a base atomic type or union type identified by the itemType attribute. Alternately, instead of referencing an existing simple type with itemType , a new anonymous atomic type for the list can be created by an xs:simpleType child element. In either case, the newly defined simple type is a whitespace-separated list of atomic values.
xs:maxExclusive |
<xs:maxExclusive fixed = "( true false )" id = " ID " value = " anySimpleType " > <!-- (xs:annotation?) --> </xs:maxExclusive>
The xs:maxExclusive facet element applies to all ordered types, including xs:decimal , xs:float , xs:double , xs:date , xs:duration , xs:dateTime , xs:time , xs:gDay , xs:gMonthYear , xs:gMonth , xs:gYear , and their subtypes. The value attribute contains the maximum value in a form appropriate for the type. For example, the maximum for a type derived from xs:integer might be 75; the maximum for a type derived from xs:double might be 1.61803; and the maximum for a type derived from xs:date might be 2004-10-26. All instances of this type must be strictly less-than the maximum value. They may not be equal to the maximum. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of maxExclusive given here.
xs:maxInclusive |
<xs:maxInclusive fixed = "( true false )" id = " ID " value = " anySimpleType " > <!-- (xs:annotation?) --> </xs:maxInclusive>
The xs:maxInclusive facet element applies to all ordered types, including xs:decimal , xs:float , xs:double , xs:date , xs:duration , xs:dateTime , xs:time , xs:gDay , xs:gMonthYear , xs:gMonth , xs:gYear , and their subtypes. The value attribute contains the maximum value in a form appropriate for the type. For example, the maximum for a type derived from xs:integer might be 75; the maximum for a type derived from xs:double might be 1.61803; and the maximum for a type derived from xs:date might be 2004-10-26. All instances of this type must be less-than or equal to the maximum value. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of maxInclusive given here.
xs:maxLength |
<xs:maxLength fixed = "( true false )" id = " ID " value = " nonNegativeInteger " > <!-- (xs:annotation?) --> </xs:maxLength>
The xs:maxLength facet element specifies the maximum number of characters in a type derived from xs:string , xs:QName , xs:anyURI , or xs:NOTATION . It can also be used to restrict xs:hexBinary and xs:base64Binary . However, in this case, it refers to the maximum number of bytes in the decoded data rather than the maximum number of characters in the encoded data. Finally, when applied to a list type, such as xs:IDREFS , it describes the maximum number of items in the list. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of maxLength given here.
xs:minExclusive |
<xs:minExclusive fixed = "( true false )" id = " ID " value = " anySimpleType " > <!-- (xs:annotation?) --> </xs:minExclusive>
The xs:minExclusive facet element applies to all ordered types, including xs:decimal , xs:float , xs:double , xs:date , xs:duration , xs:dateTime , xs:time , xs:gDay , xs:gMonthYear , xs:gMonth , xs:gYear , and their subtypes. The value attribute contains the minimum value in a form appropriate for the type. For example, the minimum for a type derived from xs:integer might be 75, the minimum for a type derived from xs:double might be 1.61803, and the minimum for a type derived from xs:date might be 2005-10-26. All instances of this type must be strictly greater-than the minimum value. They may not be equal to the minimum. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of minExclusive given here.
xs:minInclusive |
<xs:minInclusive fixed = "( true false )" id = " ID " value = " anySimpleType " > <!-- (xs:annotation?) --> </xs:minInclusive>
The xs:minInclusive facet element applies to all ordered types, including xs:decimal , xs:float , xs:double , xs:date , xs:duration , xs:dateTime , xs:time , xs:gDay , xs:gMonthYear , xs:gMonth , xs:gYear , and their subtypes. The value attribute contains the minimum value in a form appropriate for the type. For example, the minimum for a type derived from xs:integer might be 75; the minimum for a type derived from xs:double might be 1.61803; and the minimum for a type derived from xs:date might be 2005-10-26. All instances of this type must be greater-than or equal to the minimum value. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of minInclusive given here.
xs:minLength |
<xs:minLength fixed = "( true false )" id = " ID " value = " nonNegativeInteger " > <!-- (xs:annotation?) --> </xs:minLength>
The xs:minLength facet element specifies the minimum number of characters in a type derived from xs:string , xs:QName , xs:anyURI , or xs:NOTATION . It can also be used to restrict xs:hexBinary and xs:base64Binary . However, in this case, it refers to the minimum number of bytes in the decoded data, rather than the minimum number of characters in the encoded data. Finally, when applied to a list type, such as xs:IDREFS , it describes the minimum number of items in the list. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of minLength given here.
xs:notation |
<xs:notation id = " ID " name = " NCName " public = " PUBLIC identifier " system = " anyURI " > <!-- (xs:annotation?) --> </xs:notation>
The top-level xs:notation element defines a notation. It's the schema equivalent of a <!NOTATION> declaration in a DTD. Each notation has a name, a public ID, and a system ID identified by the relevant attribute on this element.
xs:pattern |
<xs:pattern id = " ID " value = " regular expression " > <!-- (xs:annotation?) --> </xs:pattern>
The xs:pattern facet element is used to derive new simple types by specifying a regular expression against which values of the type are compared. It applies to all simple types. The schema regular-expression grammar is quite similar to that used in Perl 5.6 and later. (The big change from earlier versions of Perl is support for Unicode character class-based regular expressions.) Most strings and characters match themselves, but a few characters have special meanings, as summarized in Table 22-1. In this table, A and B are subexpressions ; n and m are nonnegative integers; a , b , c , and d are all single Unicode characters; and X is a name.
Pattern | Matches |
---|---|
( A ) | A string that matches A |
A B | A string that matches A or a string that matches B |
AB | A string that matches A followed by a string that matches B |
A ? | Zero or one repetitions of a string that matches A |
A * | Zero or more repetitions of a string that matches A |
A + | One or more repetitions of a string that matches A |
A { n , m } | A sequence of between n and m strings, each of which matches A |
A { n } | A sequence of exactly n strings, each of which matches A |
A { n ,} | A sequence of at least n strings, each of which matches A |
[ abcd ] | Exactly one of the characters listed inside the square brackets |
[^ abcd ] | Exactly one character not listed inside the square brackets |
[ a-z ] | Exactly one character with a Unicode value between a and z , inclusive |
[ a-z -[ d-h ]] | Exactly one character included in the outer range but not in the inner range |
\n | The newline, 
 |
\r | The carriage return, 
 |
\t | The tab, 	 |
\\ | The backslash, \ |
\ | The vertical bar, |
\ . | The period, . |
\- | The hyphen, - |
\^ | The caret, ^ |
\? | The question mark, ? |
\* | The asterisk, * |
\+ | The plus sign, + |
\{ | The left curly brace , { |
\} | The right curly brace, } |
\( | The left parenthesis, ( |
\) | The right parenthesis, ) |
\[ | The left square bracket , [ |
\] | The right square bracket, ] |
. | Any single character except a carriage return or line feed |
\s | A space, tab, carriage return, or line feed |
\S | Any single character except a space, tab, carriage return, or line feed |
\i | An XML name-start character |
\c | An XML name character |
\d | A decimal digit |
\D | Any single character except a decimal digit |
\w | A "word character," that is, any single character that is not a punctuation mark, a separator, or "other" (as defined by Unicode) |
\W | Any single character that is a punctuation mark, a separator, or "other" (as defined by Unicode) |
\p{ X } | Any single character from the Unicode character class X ; character class names are listed in Table 22-2 |
\P{ X } | Any single character not in the Unicode character class X |
\p{Is X } | Any single character from the Unicode character block X . Block names include BasicLatin, Latin-1Supplement, LatinExtended-A, LatinExtended-B, IPAExtensions, SpacingModifierLetters, CombiningDiacriticalMarks, Greek, Cyrillic, Armenian, Hebrew, Arabic, Syriac, Thaana, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala, Thai, Lao, Tibetan, Myanmar, Georgian, HangulJamo, Ethiopic, Cherokee, UnifiedCanadianAboriginalSyllabics, Ogham, Runic, Khmer, Mongolian, LatinExtendedAdditional, GreekExtended, GeneralPunctuation, SuperscriptsandSubscripts, CurrencySymbols, CombiningMarksforSymbols, LetterlikeSymbols, NumberForms, Arrows, MathematicalOperators, MiscellaneousTechnical, ControlPictures, OpticalCharacterRecognition, EnclosedAlphanumerics, BoxDrawing, BlockElements, GeometricShapes, MiscellaneousSymbols, Dingbats, BraillePatterns, CJKRadicalsSupplement, KangxiRadicals, IdeographicDescriptionCharacters, CJKSymbolsandPunctuation, Hiragana, Katakana, Bopomofo, HangulCompatibilityJamo, Kanbun, BopomofoExtended, EnclosedCJKLettersandMonths, CJKCompatibility, CJKUnifiedIdeographsExtensionA, CJKUnifiedIdeographs, YiSyllables, YiRadicals, HangulSyllables, HighSurrogates, HighPrivateUseSurrogates, LowSurrogates, PrivateUse, CJKCompatibilityIdeographs, AlphabeticPresentationForms, ArabicPresentationForms-A, CombiningHalfMarks, CJKCompatibilityForms, SmallFormVariants, ArabicPresentationForms-B, Specials, HalfwidthandFullwidthForms, Specials, OldItalic, Gothic, Deseret, ByzantineMusicalSymbols, MusicalSymbols, MathematicalAlphanumericSymbols, CJKUnifiedIdeographsExtensionB, CJKCompatibilityIdeographsSupplement, Tags, and PrivateUse. The characters from many of these blocks are shown in Chapter 27. |
\P{Is X } | Any single character not in the Unicode character block X |
You can also include or exclude classes of Unicode characters using the \p{X} or \P{X} pattern and the classes listed in Table 22-2.
Unicode character class | Includes |
---|---|
L | Letters |
Lu | Uppercase letters |
Ll | Lowercase letters |
Lt | Titlecase letters |
Lm | Modifier letters |
Lo | Other letters |
M | All marks |
Mn | Nonspacing marks |
Mc | Spacing combining marks |
Me | Enclosing marks |
N | Numbers |
Nd | Decimal digits |
Nl | Number letters |
No | Other numbers |
P | Punctuation |
Pc | Connector punctuation |
Pd | Dashes |
Ps | Opening punctuation |
Pe | Closing punctuation |
Pi | Initial quotes |
Pf | Final quotes |
Po | Other punctuation |
Z | Separators |
Zs | Spaces |
Zl | Line breaks |
Zp | Paragraph breaks |
S | Symbols |
Sm | Mathematical symbols |
Sc | Currency symbols |
Sk | Modifier symbols |
So | Other symbols |
C | Other characters (nonletters, nonsymbols, nonnumbers, nonseparators) |
Cc | Control characters |
Cf | Format characters |
Co | Private use characters |
Cn | Unassigned code points |
xs:redefine |
<xs:redefine id = " ID " schemaLocation = " anyURI " > <!-- (annotation (simpleType complexType group attributeGroup))* --> </xs:redefine>
The xs:redefine element is used much like xs:include . That is, it inserts definitions and declarations for the same target namespace from a schema document found at a URL specified by the schemaLocation attribute. However, unlike xs:include , xs:redefine can override type, model group, and attribute group definitions from the included schema. The new type and group definitions are children of the xs:redefine element. They must extend or restrict the original definition of the redefined type or group. Note, however, that xs:redefine cannot override element and attribute declarations made in the included schema.
xs:restriction |
<xs:restriction base = " QName " id = " ID "> <!-- ( xs:annotation?, ( (xs:simpleType?, ( xs:minExclusive xs:minInclusive xs:maxExclusive xs:maxInclusive xs:totalDigits xs:fractionDigits xs:length xs:minLength xs:maxLength xs:enumeration xs:whiteSpace xs:pattern)*) ( (xs:group xs:all xs:choice xs:sequence)?, ((xs:attribute xs:attributeGroup)*, xs:anyAttribute?) ) ) --> </xs:restriction>
The xs:restriction element derives a new type from an existing base type identified by either a base attribute or an xs:simpleType child element. When deriving by restriction, all valid values of the derived type must also be legal values of the base type. However, the reverse is not true. The valid values of the derived type are a subset of the valid values of the base type. For derived simple types, the allowed values are identified by the various facet child elements of the xs:restriction element. For derived complex types, the allowed values are identified by the same elements you'd find inside an xs:complexType elementthat is, zero or one group elements such as xs:all , xs:choice , or xs:sequence followed by attribute representation elements such as xs:attribute , xs:attributeGroup , and xs:anyAttribute .
xs:schema |
<xs:schema attributeFormDefault = "( qualified unqualified )" elementFormDefault = "( qualified unqualified )" blockDefault = "( #all extension restriction substitution ) finalDefault = "( #all extension restriction ) id = " ID " targetNamespace = " anyURI " version = "token" xml:lang = "language" > <!-- ( (xs:include xs:import xs:redefine xs:annotation)*, (((xs:simpleType xs:complexType xs:group xs:attributeGroup) xs:element xs:attribute xs:notation), xs:annotation*)* ) --> </xs:schema>
xs:schema is the root element of all schema documents. It contains all the top-level elements described elsewhere in this chapter. First come all the elements that somehow reference other schema documents, including xs:include , xs:import , and xs:redefine . These are followed by the various elements that define types and groups and declare elements and attributes. As usual, xs:annotation elements can be placed anywhere that is convenient .
This sets the default value for the form attribute of xs:attribute elements. This specifies whether locally declared attributes are namespace qualified by the target namespace. If this attribute is not used, locally declared attributes are unqualified unless the form attribute of the xs:attribute element has the value qualified .
This sets the default for the form attribute of xs:element elements. This specifies whether locally declared elements are namespace-qualified by the target namespace. By default, locally declared elements are unqualified unless the form attribute of the xs:element element has the value qualified .
The blockDefault attribute establishes the default value for the block attributes of xs:element and xs:complexType elements in this schema.
The finalDefault attribute establishes the default value for the final attributes of xs:element and xs:complexType elements in this schema.
id is an XML name unique within ID-type attributes in this schema document.
The namespace URI for the XML application described by this schema. If not present, then this schema describes elements in no namespace. If the XML application uses multiple namespaces, then there must be a separate schema document for each different namespace. These schemas can be connected with xs:import elements.
You can use this attribute to specify the version of the schema, e.g., 1.0, 1.0.1, 1.1, 1.2, 1.3b1, 2.0, etc. This refers to the version of the specific schema, not the version of the W3C XML Schema Language used in this document.
This is the human language in which this schema is primarily written, such as en or fr-CA .
|
xs:selector |
<xs:selector id = " ID " xpath = "XPath expression" > <!-- (xs:annotation?) --> </xs:selector>
A single xs:selector element is placed inside each xs:unique , xs:key , and xs:keyref element to specify the element nodes for which the key or key reference is defined. The node set is selected by an XPath expression contained in the value of the xpath attribute. The context node for this XPath expression is the element matched by the xs:element declaration in which the xs:unique , xs:key , or xs:keyref element appears.
Not all XPath expressions are allowed here. In particular, the XPath expression must be an abbreviated location path that limits itself to the child axis. The only node tests used are element name, the * wildcard, and the prefix :* wildcard. Abbreviated syntax must be used; predicates are not allowed. Thus, person/name/first_name is a legal XPath expression for this attribute, but person//name and name/first_name/@id are not. Several instances of this restricted form of XPath expression can be combined with the vertical bar so that person/name/first_name person/name/last_name is also an acceptable XPath expression. Finally, the XPath expression may begin with .// so that .//name is valid. However, this is the only place the descendant-or-self axis can be used; no other forms of XPath expression are allowed here.
xs:sequence |
<xs:sequence id = " ID " maxOccurs = "( nonNegativeInteger unbounded)" minOccurs = " nonNegativeInteger " > <!-- ( xs:annotation?, ( xs:element xs:group xs:choice xs:sequence xs:any )* ) --> </xs:sequence>
The xs:sequence element indicates that the elements represented by its child elements should appear at that position in the instance document in the order they're listed here. The sequence must repeat at least minOccurs times and at most maxOccurs times. The default for both minOccurs and maxOccurs is 1. The maxOccurs attribute can be set to unbounded to indicate that the sequence may repeat indefinitely.
xs:simpleContent |
<xs:simpleContent id = " ID " > <!-- (xs:annotation?, (xs:restriction xs:extension)) --> </xs:simpleContent>
The xs:simpleContent element is used inside xs:complexType elements whose content is a simple type, such as xs:string or xs:integer , rather than child elements or mixed content. This is customarily done when the only reason an element has a complex type instead of a simple type is because it can have attributes.
xs:simpleType |
<xs:simpleType final = "( #all list union restriction )" id = " ID " name = " NCName " > <!-- (xs:annotation?, (xs:restriction xs:list xs:union)) --> </xs:simpleType>
The xs:simpleType element defines a new simple type for elements and attributes. A simple type is composed purely of text but no child elements #PCDATA , in DTD parlance. A top-level xs:simpleType element has a name given in the name attribute by which it can be referred to from the type attribute of xs:element and xs:attribute elements. Alternately, an xs:element or xs:attribute element can have an xs:simpleType child without a name attribute that defines an anonymous type for that element or attribute.
New types are derived from existing types in one of three ways: by restricting the range of a base type using an xs:restriction child element, by combining multiple base types with an xs:union child element, or by allowing multiple values of a base type separated by whitespace with an xs:list child element.
The final attribute can be used to prevent a simple type from being subtyped. If final contains the value list , the type cannot be extended by listing. If final contains the value restriction , the type cannot be extended by restriction. If final contains the value union , the type cannot become a member of a union. These three values can be combined in a whitespace-separated list. For instance, final="list union " prevents derivation by list and union but not by restriction. If final has the value #all , the type cannot be used as a base type in any way.
xs:totalDigits |
<xs:totalDigits fixed = "( true false )" id = " ID " value = " positiveInteger " > <!-- (xs:annotation?) --> </xs:totalDigits>
The xs:totalDigits facet element is used when deriving from xs:decimal elements and its descendants ( xs:integer , xs:long , xs:nonNegativeInteger , xs:unsignedLong , etc.) by restriction. It specifies the maximum number of non-zero digits allowed in the number, including both the integer and fractional parts, but not counting the decimal point or the sign. This only sets the maximum number of digits. If you want to specify a minimum number of digits, use the xs:pattern element instead. If the fixed attribute has the value true , then types derived from this type are not allowed to override the value of fractionDigits given here.
xs:union |
<xs:union id = " ID " memberTypes = "List of QName" > <!-- (xs:annotation?, (xs:simpleType*)) --> </xs:union>
The xs:union element is placed inside an xs:simpleType to indicate that an element or attribute can contain any one of multiple types. For example, it can say that an element can contain either an xs:integer or an xs:token . The names of the types that participate in the union are listed in the memberTypes attribute separated by whitespace. Furthermore, the types defined in the xs:simpleType children of the xs:union are also members of the union.
xs:unique |
<xs:unique id = " ID " name = " NCName " > <!-- (xs:annotation?, xs:selector, xs:field+ ) --> </xs:unique>
The xs:unique element requires that a specified subset of elements and/or attributes in the instance document have unique values calculated from each of those elements/attributes. This is similar to the constraint imposed by declaring an attribute to have type xs:ID , but it is much more flexible. The xs:selector child element uses XPath to specify the subset of nodes from the instance document over which uniqueness is calculated. The xs:field children use XPath expressions to specify what properties of those nodes must be unique within the subset.
xs:whiteSpace |
<xs:whiteSpace fixed = "( true false )" id = " ID " value = "(collapse preserve replace)" > <!-- (xs:annotation?) --> </xs:whiteSpace>
The xs:whiteSpace facet element is unusual because it does not constrain values. Instead, it tells the validator how it should normalize whitespace before validating the value against other facets. The value attribute has one of three values:
All whitespace is significant; this is conceptually similar to the pre element in HTML.
Before the value is validated, tabs, carriage returns, and line feeds are replaced by spaces; leading and trailing whitespace is deleted; and runs of more than one consecutive space are condensed to a single space.
Tabs, carriage returns, and line feeds are replaced by spaces before the value is validated.
For schema purposes, whitespace consists of the characters defined as whitespace in XML 1.0: the space, carriage return, tab, and line feed. It does not include the two new whitespace characters added in XML 1.1: NEL (#x85) and the Unicode line separator (#x2028).