XML technologies / XML Schema / Creating complex data types / Exploring the landscape
(Excerpt from “XML Schema” by Eric van der Vlist)
W3C XML Schema introduces many ways to model information. We will sketch the overall landscape to avoid getting lost. Two basic choices are needed: which content model to use and whether to create types or derive them from predefined ones.
Content models
Returning to content-model definitions, the table illustrates how each model relates to text and element children.
Table: Content models
Content model | Mixed | Complex | Simple | Empty |
Child elements | Yes | Yes | No | No |
Child text | Yes | No | Yes | No |
W3C XML Schema essentially provides two ways to define complex types, for complex and simple content. Tricks build mixed and empty content on these: mixed content uses attribute mixed in the complex-type definition; empty content declares neither elements nor simple content.
Named and anonymous types
Like simple data types, complex types may be named, global, or anonymous, local. Global definitions need a name and must be top-level elements directly under document element xs:schema. They can then be referenced through element attribute type directly in an element definition, and new complex types can derive from them. Local complex types are defined where needed, are anonymous without name attributes, and have only local scope.
Creation and derivation
Simple types offer no choice: new primitive types cannot be created, only types derived. Complex types are the reverse: no primitive complex types exist, so types must first be created before derivation. We can create content models from scratch or derive them by extending or restricting existing complex types. This enables reuse of complex-type libraries within and across schemas. For validation, derivation makes no difference from simpler definitions: exactly the same models and instance documents can be described. Some applications, however, may infer information from the derivation chain.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de