home contribute faq download

FunctX XQuery Functions

fn:collection

Opens a collection

Google
Webxqueryfunctions.com

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 Type

NameTypeDescription
$arg xs:string? the URI of the collection
return value node()*

Examples

XQuery ExampleResults
collection(
    'http://www.functx.com/input/coll.xml')
for example, in Saxon, this will return all the document nodes of the XML documents mentioned in http://www.functx.com/input/coll.xml.

See Also

fn:docOpens a document based on a URI

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery