Dr. Dobb's Journal - December 2007 - (Page 34) d12trem_p4ma.qxp 10/12/07 8:19 AM Page 34 Core Technology XQUERY doc("musicians.xml")/musicians /musician[birthDate>= "1960-01-01" and birthDate<"1965-01-01"] learned and used XPath, it won’t take much additional study to master XQuery. FLWOR The Relation to XPath If you are familiar with XPath, you’ll recognize the syntax of the XQuery we just executed. That’s because XQuery is built on XPath. XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators. As a matter of fact, every XPath expression is a valid XQuery. This is good news because if you have already FLWOR, an acronym for “For, Let, Where, Order by, Return,” describes a type of expression used in XQuery that is similar to the “SELECT FROM WHERE ORDER BY” you know from SQL. Here is a description of the FLWOR clauses: • for iterates over the result of an expression and binds a variable to each item returned by the expression. • let binds a variable to the result of an expression. • where filters the tuples of variable bindings that are generated by the for and let clauses. • order by specifies the order in which values are processed by the return clause. • return evaluates the expression in the clause once for each tuple of bound variables that is generated by the for, let, where, and order by clauses and concatenates the results of all the evaluations into a single sequence, which becomes the result of the FLWOR expression. .NET, ActiveX, and C Libraries Available Functions The practice of placing frequently used segments of code into functions is common to all programming languages. XQuery is no different. We have already mentioned that XQuery supports the same functions as XPath. There are over 100 built-in functions (for a summary, see www.w3schools.com/xpath/xpath_functions .asp). You can also write your own functions. XQuery functions exist within a namespace. Each function name consists of a prefix that is a shortcut to the namespace followed by a colon followed by the function name. The default prefix, which you can see in the list of built-in functions, is fn:. For user-written functions, you can use the prefix local:. A function that uses a FLWOR expression to perform the equivalent of the join with which you are familiar from SQL is printBandMemberInstrument (available online). It joins musicians.xml, which we have already seen, and band.xml (which is also available online). Notice that the return clause can contain XML tags as well as data. The stress-free choice for document imaging is Pegasus Imaging. Pegasus Imaging brings over 15 years of imaging experience and support to your software when you accelerate development using our .NET and ActiveX toolkits. Don’t take a chance on the unknown. Choose the leader in image compression, recognition, and editing technologies. Choose Pegasus Imaging. To learn more, visit our website today. Forms Processing Zonal & Full-Page OCR ICR OMR Barcode Annotation Image Viewing Scanning File Conversion Image Compression Multi-page Document Support Image Cleanup Conclusion XQuery provides the same power and flexibility for XML as SQL does for relational data. XQuery also makes it possible for you to query office documents—spreadsheets, word-processing documents, and the like. For more details, see Marc Van Cappellen’s article “XQuery Your Office Documents” (www. d d j. c o m / l i n u x- o p e n -s o u r c e / 202401913). DDJ WWW.PEGASUSIMAGING.COM (800) 875-7009 Pegasus is a registered trademark of Pegasus Imaging Corporation in the United States. Microsoft is a registered trademark of Microsoft Corporation in the United States and/or other countries. 34 Dr. Dobb’s Journal l www.ddj.com l December 2007 http://www.w3schools.com/xpath/xpath_functions.asp http://www.w3schools.com/xpath/xpath_functions.asp http://www.pegasusimaging.com http://www.pegasusimaging.com http://www.pegasusimaging.com http://www.ddj.com/linux-open-source/202401913 http://www.ddj.com/linux-open-source/202401913 http://www.ddj.com
Table of Contents Feed for the Digital Edition of Dr. Dobb's Journal - December 2007 Dr. Dobb's Journal - December 2007 Contents Hmmmm Alia Vox Developer Diaries Developer’s Notebook Computer Books: Reading Between the Lines Conversations Query Anything with SQLite XQuery Web Maps with the Google Map API OpenALM and Its Manifesto Transactional Programming Effective Concurrency The Agile Edge Swaine’s Flames Dr. Dobb's Journal - December 2007 Dr. Dobb's Journal - December 2007 - Dr. Dobb's Journal - December 2007 (Page Cover1) Dr. Dobb's Journal - December 2007 - Dr. Dobb's Journal - December 2007 (Page Cover2) Dr. Dobb's Journal - December 2007 - Dr. Dobb's Journal - December 2007 (Page 1) Dr. Dobb's Journal - December 2007 - Dr. Dobb's Journal - December 2007 (Page 2) Dr. Dobb's Journal - December 2007 - Dr. Dobb's Journal - December 2007 (Page 3) Dr. Dobb's Journal - December 2007 - Contents (Page 4) Dr. Dobb's Journal - December 2007 - Contents (Page 5) Dr. Dobb's Journal - December 2007 - Hmmmm (Page 6) Dr. Dobb's Journal - December 2007 - Hmmmm (Page 7) Dr. Dobb's Journal - December 2007 - Hmmmm (Page 8) Dr. Dobb's Journal - December 2007 - Hmmmm (Page 9) Dr. Dobb's Journal - December 2007 - Alia Vox (Page 10) Dr. Dobb's Journal - December 2007 - Alia Vox (Page 11) Dr. Dobb's Journal - December 2007 - Developer Diaries (Page 12) Dr. Dobb's Journal - December 2007 - Developer Diaries (Page 13) Dr. Dobb's Journal - December 2007 - Developer’s Notebook (Page 14) Dr. Dobb's Journal - December 2007 - Developer’s Notebook (Page 15) Dr. Dobb's Journal - December 2007 - Computer Books: Reading Between the Lines (Page 16) Dr. Dobb's Journal - December 2007 - Computer Books: Reading Between the Lines (Page 17) Dr. Dobb's Journal - December 2007 - Computer Books: Reading Between the Lines (Page 18) Dr. Dobb's Journal - December 2007 - Computer Books: Reading Between the Lines (Page 19) Dr. Dobb's Journal - December 2007 - Conversations (Page 20) Dr. Dobb's Journal - December 2007 - Conversations (Page 21) Dr. Dobb's Journal - December 2007 - Conversations (Page 22) Dr. Dobb's Journal - December 2007 - Conversations (Page 23) Dr. Dobb's Journal - December 2007 - Query Anything with SQLite (Page 24) Dr. Dobb's Journal - December 2007 - Query Anything with SQLite (Page 25) Dr. Dobb's Journal - December 2007 - Query Anything with SQLite (Page 26) Dr. Dobb's Journal - December 2007 - Query Anything with SQLite (Page 27) Dr. Dobb's Journal - December 2007 - Query Anything with SQLite (Page 28) Dr. Dobb's Journal - December 2007 - Query Anything with SQLite (Page 29) Dr. Dobb's Journal - December 2007 - XQuery (Page 30) Dr. Dobb's Journal - December 2007 - XQuery (Page 31) Dr. Dobb's Journal - December 2007 - XQuery (Page 32) Dr. Dobb's Journal - December 2007 - XQuery (Page 33) Dr. Dobb's Journal - December 2007 - XQuery (Page 34) Dr. Dobb's Journal - December 2007 - XQuery (Page 35) Dr. Dobb's Journal - December 2007 - Web Maps with the Google Map API (Page 36) Dr. Dobb's Journal - December 2007 - Web Maps with the Google Map API (Page 37) Dr. Dobb's Journal - December 2007 - Web Maps with the Google Map API (Page 38) Dr. Dobb's Journal - December 2007 - Web Maps with the Google Map API (Page 39) Dr. Dobb's Journal - December 2007 - Web Maps with the Google Map API (Page 40) Dr. Dobb's Journal - December 2007 - Web Maps with the Google Map API (Page 41) Dr. Dobb's Journal - December 2007 - OpenALM and Its Manifesto (Page 42) Dr. Dobb's Journal - December 2007 - OpenALM and Its Manifesto (Page 43) Dr. Dobb's Journal - December 2007 - OpenALM and Its Manifesto (Page 44) Dr. Dobb's Journal - December 2007 - OpenALM and Its Manifesto (Page 45) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 46) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 47) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 48) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 49) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 50) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 51) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 52) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 53) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 54) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 55) Dr. Dobb's Journal - December 2007 - Transactional Programming (Page 56) Dr. Dobb's Journal - December 2007 - Effective Concurrency (Page 57) Dr. Dobb's Journal - December 2007 - Effective Concurrency (Page 58) Dr. Dobb's Journal - December 2007 - Effective Concurrency (Page 59) Dr. Dobb's Journal - December 2007 - The Agile Edge (Page 60) Dr. Dobb's Journal - December 2007 - The Agile Edge (Page 61) Dr. Dobb's Journal - December 2007 - The Agile Edge (Page 62) Dr. Dobb's Journal - December 2007 - The Agile Edge (Page 63) Dr. Dobb's Journal - December 2007 - Swaine’s Flames (Page 64) Dr. Dobb's Journal - December 2007 - Swaine’s Flames (Page Cover3) Dr. Dobb's Journal - December 2007 - Swaine’s Flames (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.