Abstract:
To provide flexibility to users of the document, designers can provide an element type that is very generic. The use of the generic element is not well specified by the documents type. This allows for authors to use the document type in ways that may not have been foreseen.
Problem:
The designer does not know exactly what the users of the document intend to do with the document and needs to add flexibility to the document type.
Context:
This is useful in general purpose document types, when flexibility is needed.
Forces:
Flexibility is required to make some document types useful. This pattern can effect the ease of processing of the document type.
Solution:
Provide a new element that does not have a specific meaning.
Examples:
<Paragraph>
Albert Camus' <General type="book">The Stranger</General>
is an existentialist novel.
</Paragraph>
Discussion:
Not providing enough flexibility can make document authors use the wrong element for markup. This can lead to documents that are difficult to understand, and mistakes in processing occur.
This flexibility can make processing software difficult to create. Adding
Role Attributes to the generic element can help provide the processing software some clues as to how to process the element.
Related Patterns:
A
Role Attribute is often used in conjunction with Generic Elements.
References:
The Fielded Text example from
The XML & SGML Cookbook page 2-48, uses Generic Elements.