Monday, 2 January 2012

XSD Schema Components Details

Component Details
element and attribute declaration There is a distinction between "definitions" which create new types and "declarations" which enable elements and attributes with specific names and types to appear in document instances. Global element and attribute declarations cannot contain the "Ref" attribute, they must use the "type" attribute or be followed by an anonymous type definition. No occurence constraints (minOccurs, maxOccurs, use) may appear in the declarations of global elements and attributes. To represent a "null" value with an element that is present, e.g. when being sent to or from a relational database, set the "xsi:nil" attribute to "true"
simple type definition Attributes always have simple types. Simple types are built by restriction (facets), list or union. The 12 simple type restriction facets are:
  • maxInclusive
  • maxExclusive
  • minInclusive
  • minExclusive
  • totalDigits
  • fractionDigits
  • length
  • minLength
  • maxLength
  • pattern
  • enumeration
  • whiteSpace
complex type definition Elements that contain subelements/children or carry attributes are said to have complex types, whereas elements that contain strings/numbers/dates/... but do not contain any subelements are said to have simple types. Every complex type definition defines its own local (non-global) scope. Complex type content models:
  • simpleContent (no elements)
  • complexContent (some elements)
  • named group ("group")
  • un-named group ("choice", "sequence", "all")
model and attribute group definition Model and attribute group definitions do not participate in validation as such, but other components may be constructed in whole or part by reference to these groups. Thus, model and attribute group definitions provide a replacement for some uses of XML's parameter entity facility
identity-constraint definition Identity-constraint definition components provide for uniqueness and reference constraints with respect to the contents of multiple elements and attributes: unique, key (unique not null), keyref
notation declaration Reconstructs XML notation declarations. Notation declarations do not participate in validation as such. They are referenced in the course of validating strings as members of the NOTATION simple type
model groups Possible compositors:
  • choice
  • sequence
  • all
particles The minOccurs/maxOccurs attributes apply to "terms": elements, groups or wildcards. The default value for both the minOccurs and the maxOccurs attributes is 1. If both attributes are omitted, the term must appear exactly once
attribute uses Attributes can be declared with a "use" attribute to indicate whether the attribute is required, optional, or even prohibited (same usage as minOccurs/maxOccurs for terms). Default attribute values apply when attributes are missing while default element values apply when elements are empty. If an element does not appear in the instance document (i.e. it is missing), the schema processor does not provide the element at all, even if it has a default content
wildcards anyType represents the base type from which all simple and complex types are derived. An anyType type does not constrain its content in any way. anyType is the default type when none is specified. An "any" element specifies that any well-formed XML is permissible as content (processContents = skip/lax/strict)
annotation Annotations provide for human- and machine-targeted annotations of schema components ("documentation" resp. "appinfo")