Declaring Types and Elements

The most basic thing to understand about XML schemas is the concept of using simple and complex types, and how they relate to declaring elements. In schemas, unlike DTDs, you specify the type of the elements you declare.

That means that the first step in declaring elements is to make sure you have the types you want—and that often means defining new complex types. Complex types can enclose elements and have attributes, and simple types cannot do either. You can find the simple types built into XML schemas in Table 5-3. (When you specify these types in schemas, bear in mind that you'll preface them with the W3C schema prefix, usually xsd:.)

Table 5-3. Simple Types Built into XML Schema
Type Examples
anyURI http://www.starpowder.com ...

Get Real World XML 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.