Catch-All Element

Abstract

A container element for dealing with unknown elements within the document.

Problem

Users need to be able to insert marked up text into the document that the document designer cannot foresee. For example, it is often necessary to have some presentation specific markup inside of a document. If this unexpected markup is spread throughout the document, then processors might have a hard time dealing with it.

Context

When documents are going to need to have the flexibility to include elements from other namespaces.

Forces

Allowing elements from other document types allows you to save development costs and time by reusing schemas instead of developing them.

Allowing documents to use other schemas allows for great flexibility.

Solution

Create a new element which will serve as a container for elements of a new schema.

Examples

This example shows how a document that describes a car would allow a comment element that includes elements from HTML.

For details on the use of the any element see: The XML Schema Part 0: Primer Section 5.5 Any Element, Any Attribute (http://www.w3.org/TR/xmlschema-0/#any)

Discussion

The element within the catch-all element are from a namespace outside of the namespace of the document-type being created.

This tag acts as a warning to processors that some markup from another namespace is about to be encountered.

Related Patterns

The
Envelope pattern uses a similar mechanism, but the intent of the Envelope is to wrap a document without adding any domain data of its own. The intent of the Catch-All Element is to allow authors to mix data from separate document types.

Known Uses

The Real Estate DTD
RELML (http://www.csn.net/public/design/rsdesign.html) uses an
OTHER as a catch all element.