Direct constructors
In XQuery, there are two ways to generate XML content: direct constructors and computed constructors. Direct constructors look like normal XML but allow XQuery expressions to be embedded and executed inside the constructor.
For example, the following XQuery expression computes elements, comments, and attributes including a computed attribute value and a computed element value.
<zing>
<!– normal xml comment –>
<whizz bling=”true” value=”{ concat(”a”, “b”) }”>
<goat>{ 1 + 2 }</goat>
</whizz>
</zing>
This will produce the following XML output:
<zing>
<!– normal xml comment –>
<whizz bling=”true” value=”ab”>
<goat>3</goat>
</whizz>
</zing>
Dynamic values can only be computed for attribute and element content in direct constructors. Computed constructors allow you to also dynamically compute or build the actual names of the tags and all other parts of the various node types.
