Catch-All Element


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


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.


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


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.


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


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

  <xhtml:p xmlns:xhtml="http://www.w3.org/1999/xhtml">
   This car <xhtml:b>runs great!</xhtml:b>


To allow this type of inclusion using an XML Schema, use the any element as follows:

<element name="car">
     <element name="model" type="string"/>
     <element name="year"   type="string"/>
     <element name="comment">
        <any namespace="http://www.w3.org/1999/xhtml"
             minOccurs="1" maxOccurs="unbounded"

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)


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.