C
XML Schema Data Types
This appendix shows the data types available for use in W3C XML Schemas, which were covered in Chapter 5.
THE TREE OF TYPES
The types in XML Schema follow the traditional pattern of a tree found in many other software libraries. For example, in Java the basic type is Object from which all other classes ultimately derive. The inheritance tree for the XML Schema types is shown in Figure C-1.
As you can see, all W3C Schema types are based on anyType. From here come all the built-in types, or you can create a complex type using restriction and extension, as detailed in Chapter 5.
These types are all grouped under the namespace http://www.w3.org/2001/XMLSchema. It is common to use a prefix of xs or xsd to represent this namespace URI but, because all the types discussed in this appendix fall under this namespace, no prefix is used when specifying them.
Most of the types shown can be constrained, that is they can be limited to hold a narrower range of data than originally intended. This is because the types have a number of facets. Each facet allows you to specify a property of the type. For example, the double type has a facet called minInclusive. This means you can specify the minimum value that can be held by this type. If you specified 0 for this property, your type would not be able to contain any negative values. Another common facet is pattern ...
Get Beginning XML, 5th 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.