XML Schema (W3C) - Types

Types

Complex types describe the permitted content of an element, including its element and text children and its attributes. A complex type definition consists of a set of attribute uses and a content model. Varieties of content model include element-only content, in which no text may appear (other than whitespace, or text enclosed by a child element); simple content, in which text is allowed but child elements are not; empty content, in which neither text nor child elements are allowed; and mixed content, which permits both elements and text to appear. A complex type can be derived from another complex type by restriction (disallowing some elements, attributes, or values that the base type permits) or by extension (allowing additional attributes and elements to appear). In XSD 1.1, a complex type may be constrained by assertions — XPath 2.0 expressions evaluated against the content that must evaluate to true.

Simple types (also called data types) constrain the textual values that may appear in an element or attribute. This is one of the more significant ways in which XML Schema differs from DTDs. For example, an attribute might be constrained to hold only a valid date or a decimal number.

XSD provides a set of 19 primitive data types (anyURI, base64Binary, boolean, date, dateTime, decimal, double, duration, float, hexBinary, gDay, gMonth, gMonthDay, gYear, gYearMonth, NOTATION, QName, string, and time). It allows new data types to be constructed from these primitives by three mechanisms:

  • restriction (reducing the set of permitted values),
  • list (allowing a sequence of values), and
  • union (allowing a choice of values from several types).

Twenty-five derived types are defined within the specification itself, and further derived types can be defined by users in their own schemas.

The mechanisms available for restricting data types include the ability to specify minimum and maximum values, regular expressions, constraints on the length of strings, and constraints on the number of digits in decimal values. XSD 1.1 again adds assertions, the ability to specify an arbitrary constraint by means of an XPath 2.0 expression

Read more about this topic:  XML Schema (W3C)

Famous quotes containing the word types:

    The bourgeoisie loves so-called “positive” types and novels with happy endings since they lull one into thinking that it is fine to simultaneously acquire capital and maintain one’s innocence, to be a beast and still be happy.
    Anton Pavlovich Chekhov (1860–1904)

    The rank and file have let their servants become their masters and dictators.... Provision should be made in all union constitutions for the recall of leaders. Big salaries should not be paid. Career hunters should be driven out, as well as leaders who use labor for political ends. These types are menaces to the advancement of labor.
    Mother Jones (1830–1930)

    Science is intimately integrated with the whole social structure and cultural tradition. They mutually support one other—only in certain types of society can science flourish, and conversely without a continuous and healthy development and application of science such a society cannot function properly.
    Talcott Parsons (1902–1979)