Chapter 8. Functions

Functions are a useful feature of XQuery that allow a wide array of built-in functionality, as well as the ability to modularize and reuse parts of queries. There are two kinds of functions: built-in functions and user-defined functions.

Built-in Versus User-Defined Functions

The built-in functions are a standard set, defined in the Functions and Operators recommendation and supported by all XQuery implementations. A detailed description of each built-in function is provided in Appendix A, and most are also discussed at appropriate places in the book.

The Functions and Operators recommendation defines built-in operators in addition to functions. These operators are like functions, but they cannot be called directly from a query; instead, they back up a symbol or keyword in the XQuery language. For example, the numeric-add operator backs up the + sign when both operands are numeric. Because they are internal to the implementation, and not used by the query author, they are not discussed directly in this book.

A user-defined function is one that is specified by a query author, either in the query itself, or in an external library. The second half of this chapter explains how to define your own functions in detail.

Get XQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.