ComputedDocumentConstructor

A ComputedDocumentConstructor constructs a document node with a new node identity. The result of evaluating the ExprSequence yields the child nodes of the conctructed document node.

Top of page

Related Syntax Constructs

The following construct(s) refer to this construct:


Syntax

graphics/ComputedDocumentConstructor.png

Description

When creating an XML document node, the result of the evaluation of the ExprSequence must be well-formed XML, i.e.:

  • it may contain comment or processing instruction nodes;

  • it must contain exactly one element node;

  • it must not contain any attribute nodes or text nodes.

Any XML document nodes contained in that sequence are implicitly replaced by their child nodes. For XML document construction, the sequence must not contain any simple type values.

In Tamino XQuery, a document constructor can also be used to create a non-XML document node. In this case the following applies to the result of evaluating the ExprSequence:

  • It may be empty. This will result in an empty non-XML document.

  • It may be a non-XML document node. This results in a non-XML document node with the same content (but a new node identity). Also the content-type is inherited from the source document.

  • It may be a string value. This creates a non-XML text document with the string as its text content.

The ExprSequence must not result in both XML and non-XML content.

For creating documents with extra options (content-type, ACL), see the function tf:document().

Examples

  • This query creates an XML document node of a book document:

    document { <book><title></title></book> }
  • This query contains a non-XML document holding the source text of an XQuery module:

    document {"module namespace m='M'; declare function m:f() {'F'};"}