xsd

Topics related to xsd:

Getting started with xsd

XML Schema is a language and framework for validating XML documents.

An XML document that is well-formed, in the sense that it is syntactically conformant to the XML specification, can be tested for validity against a schema. The distinction between well-formedness, which is absolute, and validity, which is relative to a schema, is paramount.

Validation encompasses:

  • Checking whether the XML document fulfils additional requirements such as the elements having certain names, restrictions on the content of elements, consistency constraints (primary keys, uniqueness, etc), attribute values or text matching certain types.
  • Upon success, conversion of the input data model instance (called XML Infoset) to an output instance (PSVI: Post-Schema-Validation Infoset), where elements and attributes are annotated with type information, where default values have been populated, etc.

XML Schema was introduced to address requirements that DTD validation failed to address, among others a more complete type system including a rich set of builtin types, type restriction and extension capabilities, and more control on the restriction of element layout.

xs:complexType

Deriving from a xs:complexType

When a xs:complexType derives from another xs:complexType is can do it via extension or restriction.

  • extension - the deriving type takes everything defined in the base type and adds to it.
  • restriction - the deriving type takes only selected parts from the base type, only allowing the parts it wants, no additional items can be added.

Deriving from a xs:simpleType

When a xs:complexType derives from a xs:simpleType is can do it via extension, in which case it can add attributes to the resulting type, but not elements.

Content Type

Conceptually a xs:complexType either contains simple or complex content. If the xs:complexType derives from a typed based on xs:anySimpleType (xs:int, xs:string etc) then it is simple. If it derives from a xs:complexType which contains complex content, then it itself is complex (if the xs:complexType does not derive from a type, then it is also complex).

xs:schema