Summary


This chapter started with a brief introduction to XQuery by discussing the role of XQuery, its advantages and the structure of an XQuery expression. After that, you looked at one of the key aspects of XQuery-FLWOR expressions that provide you with a consistent way to write and execute query expressions. FLWOR expressions are the central feature of the XQuery language, in the same way as path expressions are at the heart of XPath. Specifically:

  • q FLWOR expressions have five clauses: for, let, where, order by, and return. The first two can appear any number of times in any order. The where and order by clauses are optional, but if used, they must appear in the order given. There is always a return clause.

  • q The semantics are similar to those of a SELECT statement in SQL. In most cases, you can think of a FLWOR expression with multiple for clauses as a set of nested loops, but a sorting using order using a rather more complex execution model is needed.

  • q You can use FLWOR expressions anywhere that you can use any other kind of expression. This means the expressions can be nested within each other, and they can appear in contexts such as an argument to a function like count() or max(). The only constraint is that the type of value returned by the FLWOR expression (a sequence of items) must be appropriate to the context where the expression is used.

After that, you learned the various functions supported by XQuery including the use of built-in and user-defined functions. You also explored the steps involved in using XQuery from within a Java program through an XMLBeans open-source implementation. As part of this, you learned the two ways of executing XQuery expressions from within a Java application: through XmlObject and XmlCursor. Examples showed you the XQuery implementation in SQL Server 2005.

Now is as good a time as any to start learning XQuery, because it's bound to become more prominent as XML data stores continue their meteoric rise. Furthermore, with the deep XQuery support provided by SQL Server 2005, it is only a matter of time before XQuery becomes pervasive.




Professional XML
Professional XML (Programmer to Programmer)
ISBN: 0471777773
EAN: 2147483647
Year: 2004
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net