Message model objects: attributes

An attribute describes an XML attribute.

Attributes are provided to simplify the modeling of XML messages; if none of your messages use the XML physical format, use simple elements instead.

Attributes and XML

The most common use for an attribute is to model an XML attribute within an XML message. In this scenario, each attribute that can appear in the XML message has a corresponding attribute in the logical message definition.

Attributes in other physical formats

Sometimes a message needs to be parsed as XML, but written in another physical format (Custom Wire Format or Tagged Delimited String Format). In this case, any attributes in the message are treated in exactly the same way as simple elements with the same properties.

Global and local attributes

Attributes can be global or local.

A global attribute can be used in more than one place in the message model. It must be given a unique name by which it can be referenced.

A local attribute is defined in one position within one complex type, and cannot be used elsewhere in the message model.

Optional attributes

Attributes can be defined as optional, required or prohibited. Attributes are not allowed to repeat. For further information, see Cardinality: optional, repeating and mandatory elements.

Default and fixed values

An attribute can be given a default value so that, if the attribute is missing from the message, the default is used. Alternatively, a fixed value can be defined, and the attribute always takes that value. The precise use of default and fixed values is domain dependent.

Value constraints

An attribute's value can be constrained by using value constraints, which define the range of legal values for the attribute. Value constraints are associated with the simple type on which the attribute is based. For more details, see Message model objects: simple types. In XML Schema, the term for value constraint is facet.

Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2009Copyright IBM Corporation 1999, 2009.
Last updated : 2009-01-07 15:21:02

ad10420_