5.9 The Collection Node

MonetDB/XQuery provides efficient support for large collections of small XML documents by storing these together in a XML Collection (see Separate Documents vs Document Collections).

An XML collection, as identified by the standard function fn:collection, is considered to be a sequence of document nodes.

However, in MonetDB/XQuery, a collection is actually stored as an XML Tree, by putting a special collection node on top.

This is a non-standard implementation of XML Data Model, that in most aspects is just a hidden feature of the MonetDB/XQuery storage system, because in normal use the collection node is invisible.

That is, XPath steps will never return a collection node. However, when the downward axes child::node() and descendant::* (or shorter /node() and //*) are given the collection node as input, they do work. That is, all document nodes of the XML documents in the collection are returned by the child::* step and descendant::* reaches all nodes in the entire collection.

The built-in extension function:

pf:collection($coll as xs:string) as node()

provides you this special collection node. The reason for its introduction is performance-related: when the default fn:collection would yield thousands or millions of results, the use of pf: rather than fn: can make a difference; especially in combination with the use of element or value indices.