O'Reilly logo

XQuery from the Experts: A Guide to the W3C XML Query Language by Philip Wadler, Jim Tivy, Jérôme Siméon, Michael Rys, Jonathan Robie, Michael Kay, Mary Fernández, Denise Draper, Don Chamberlin, Howard Katz - Editor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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
&lt;<
&gt;>
&amp;&
&quot;"
&apos;'

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

doc("books.xml")

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required