Computed attribute constructors
A computed attribute constructor creates an attribute node for which the attribute value is computed based on an enclosed expression.
The result of a computed attribute constructor is
a new attribute node that has its own node identity.
Note: To construct an
attribute node directly, declare the attribute in a direct element constructor.
Syntax
- attribute
- A keyword that indicates that an attribute node will be constructed.
- AttributeName
- The QName of the attribute to construct. If AttributeName includes a namespace prefix, the prefix is resolved to a namespace URI by using the statically known namespaces. If AttributeName has no namespace prefix, the attribute is in no namespace. The expanded QName that results from evaluating AttributeName becomes the name of the constructed attribute node. The expanded QName of each attribute in an element must be unique, or the expression results in an error.
- AttributeValueExpression
- An expression that generates the value of the attribute node. During processing, atomization is applied to the result of AttributeValueExpression, and each atomic value in the resulting sequence is cast to a string. The individual strings that result from the cast are concatenated with an intervening space character. The concatenated string becomes the value of the constructed attribute node.
Example
The following computed attribute
constructor constructs an attribute named size with a value of "7".
attribute size {4 + 3}