Some schemas hammer every possible element and attribute down in place, building extremely restrictive content models that allow processing applications to do less work interpreting documents. Other schemas leave nearly everything open, describing elements and attributes only loosely. XML is capable of accommodating both of these approaches, even in its more constrictive validating environment.
Data-oriented applications, especially those where information within XML document is mapped directly to internal structures, will typically want schemas with as restrictive a model as possible, where as little as possible is optional and most items can only appear once. This allows applications to rely more heavily on XML 1.0 validation and reduces the amount of code the application developer has to create to support imported information. Schemas that are built exclusively for data interchange may have a strict set of rules that reflects the need for a precise set of information.
Document-oriented applications typically have a more open approach to schemas, but still require some kinds of structure. Document structures are rarely as restrictive as data structures. Very few documents reliably contain only a single paragraph, for instance, and content-specific markup can typically appear throughout a document. Though schema designers can restrict the use of markup to some extent, there are typically many options that authors can use throughout a document.
XML provides a convenient tool that lets schema designers open up their element content models completely, the ANY content model for elements. ANY is often useful in the earliest stages of schema development if you're just sketching possibilities. As a schema grows, however, the use of ANY is often seen as a vice. There are some legitimate uses for ANY - it provides an extension mechanism creating a space that other developers can fill with their own markup. While that markup may be unintelligible to applications lacking the tools to make sense of it, these 'extension areas' can be left as optional sources of additional information for applications rather than mandatory information the application needs to process.
ANY is the default content model for new elements created in XML Authority. When the Text and Elements checkboxes are selected and no content model is specified, the element has an ANY content model. XML Authority's approach makes it possible to create loose structures and fill them in as you go along.
Leaving an attribute value unconstrained has less drastic consequences, as attributes can't contain additional levels of markup. XML Authority defaults attributes to containing text (CDATA), with no default value and not required. Effectively, this allows authors to use the attribute without requiring it to be present. This is acceptable in many cases, though you can, if necessary, constrain the attribute values with a list of possibilities or a more constrictive data type.
As a general rule, it's a good idea to create schemas that are as restrictive as still feels comfortable. This allows applications to take maximum advantage of the services provided by schema validation, without necessarily locking document creators using your schema into a small set of choices that may not fit the needs of the information being presented. If you must use ANY, try to cordon it off in an area designated for extensions, and make as little use of it as possible.
Copyright 2000 Extensibility, Inc.
Suite 250, 200 Franklin Street, Chapel Hill, North Carolina 27516