Description
The fn:collection function returns a collection. which may be any sequence of nodes, identified by a URI. Often it returns the document nodes of a number of documents. Exactly how the URI is associated with the nodes is defined by the implementation. Saxon, for example, dereferences $arg to retrieve an XML collection document that lists all of the documents in the collection. A database implementation might allow you define collections (and add documents to them) using the product's user interface.
If $arg is a relative URI, it is resolved based on the base URI of the static context. The base URI of the static context may be set by the processor outside the scope of the query, or it may be declared in the query prolog.
The fn:collection function is stable. This means that if you call the fn:collection function more than once with the exact same argument, within the same query, the result is the same, even if somehow the resources associated with the URI have changed.
This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book. Arguments and Return TypeName | Type | Description |
$arg |
xs:string? |
the URI of the collection |
return value |
node()* |
ExamplesXQuery Example | Results |
---|
collection(
'http://www.datypic.com/functx./input/coll.xml') |
for example, in Saxon, this will return all the document nodes of the XML documents mentioned in http://www.datypic.com/functx./input/coll.xml. |
See Alsofn:doc | Opens a document based on a URI |
History |
Recommended Reading:
|