Name

xs:simpleType

Synopsis

<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 ...

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.