Format: PDF / Kindle (mobi) / ePub
With the XQuery 1.0 standard, you finally have a tool that will make it much easier to search, extract and manipulate information from XML content stored in databases. This in-depth tutorial not only walks you through the XQuery specification, but also teaches you how to program with this widely anticipated query language.
XQuery is for query writers who have some knowledge of XML basics, but not necessarily advanced knowledge of XML-related technologies. It can be used both as a tutorial, by reading cover to cover, and as a reference, by using the comprehensive index and appendixes. Either way, you will find the background knowledge in namespaces, schemas, built-in types and regular expressions that is relevant to writing XML queries. This book provides:
- A high-level overview and quick tour of XQuery
- Information to write sophisticated queries, without being bogged down by the details of types, namespaces, and schemas
- Advanced concepts for users who want to take advantage of modularity, namespaces, typing and schemas
- Guidelines for working with specific types of data, such as numbers, strings, dates, URIs and processing instructions
- A complete alphabetical reference to the built-in functions and types
You will also learn about XQuery's support for filtering, sorting, and grouping data, as well as how to use FLWOR expressions, XPath, and XQuery tools for extracting and combining information. With this book, you will discover how to apply all of these tools to a wide variety of data sources, and how to recombine information from multiple sources into a single final output result.
Whether you're coming from SQL, XSLT, or starting from scratch, this carefully paced tutorial takes you through the final 1.0 standard in detail.
representing common datatypes such as xs:integer, xs:string, and xs: date. The xs: prefix is used to indicate that these types are defined in the XML Schema specification. Types are assigned to items in the input document during schema validation, which is optional. If no schema is used, the items are untyped. The type system of XQuery is not as rigid as it may sound, since there are a number of type conversions that happen automatically. Most notably, items that are untyped are automatically
function signature. If there is more than one signature, as in the case of the substring function, the argument list may match either function signature. If the function does not take any arguments, the parentheses are still required, although there is nothing between them, as in: current-date( ) You are not limited to simple variable names and literals in a function call. You can have complex, nested expressions that are evaluated before evaluation of the function. For example, the following
function declaration that has the same qualified name, as long as the number of parameters is different. The function name must be a valid XML name, meaning that it can start with a letter or underscore and contain letters, digits, underscores, dashes, and periods. Like other XML names, function names are case-sensitive. All user-defined function names must be in a namespace. In the main query module, you can use any prefix that is declared in the prolog. You can also use the predefined prefix
Hat The location of the namespace declarations in the results of Example 10-9 are different from those of Example 10-7, although the two results are technically equivalent. This subtle difference is explained in “Controlling Namespace Declarations in Your Results,” later in this chapter. As with prolog namespace declarations, the namespace name used in a namespace declaration attribute must be a literal value, not an enclosed expression, and it should be
constructors shown in these examples are known as direct constructors, because they use an XML-like syntax. You can also construct elements and attributes with dynamically determined names, using computed constructors. Chapter 5 provides detailed coverage of XML constructors. Functions There are over 100 functions built into XQuery, covering a broad range of functionality. Functions can be used to manipulate strings and dates, perform mathematical calculations, combine sequences of elements, and