Input Functions

XQuery uses input functions to identify the data to be queried. There are two input functions:

  1. doc() returns an entire document, identifying the document by a Universal Resource Identifier (URI). To be more precise, it returns the document node.

  2. collection() returns a collection, which is any sequence of nodes that is associated with a URI. This is often used to identify a database to be used in a query.

Table 1.1. Entity References Predefined in XQuery
Entity ReferenceCharacter Represented

If our sample data is in a file named books.xml, then the following query returns the entire document:


A dynamic error is raised if the doc() function is not able to locate the specified document ...

Get XQuery from the Experts: A Guide to the W3C XML Query Language now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.