Tuesday, May 5, 2009

DB2 pureXML: All the XQuery features you need

One question I hear a lot is: What XQuery features are supported by DB2 pureXML? My standard answer is "All the features you need!". But what are they?

XQuery itself is built on top of XQuery/XPath Data Model (XDM), the XQuery and XPath Functions and Operators, and some other stuff. The two referenced specs alone are already complex by themselves and guarantee hours of reading fun. A different way of reading through XQuery, its syntax and functions is to go to the DB2 Information Center and its XQuery Reference. It provides a really good introduction into XQuery from the DB2 or database angle. The documentation includes a comparison of SQL and XQuery, an overview of the XQuery data model, and of course the description of expressions, functions, and all the other supported features.

After you are done reading AND trying it out, let me know if you don't agree on "DB2 pureXML: All the XQuery features you need"...

2 comments:

Torsten Grust said...

Hi Henrik,

when you say "All the features you need!", I'd almost subscribe to that. One XQuery feature that's missing, however, are user-defined, potentially recursive(!), functions.

The core of the XQuery data model is the ordered unranked tree, a prototypical recursive data structure. The lack of user-defined recursion, in a sense, thus makes for a mismatch between the data model and the computation model. This can hurt.

I fully understand, though, that support for general recursion is tough if your execution engine is relational at heart.

Best wishes,
--Torsten

Henrik Loeser said...

Hello Torsten,

First of all, thank you for your feedback (and I know that you know pureXML).

For the user-defined functions let me point to the SQL part where XML/XQuery functionality can be used in user-defined functions and procedures. Stored procedures can be quite powerful and quite some effort went into XML-related optimizations.

In terms of recursion I would like to quote L Peter Deutsch: "To iterate is human, to recurse divine." Recursion can be very handy, but often it causes lots of trouble. SQL has the Common Table Expression to offer bits of recursion (where you can use XML functions). From my experience and experiments with XQuery and recursion I can report that the chances to get something wrong or even cause damage are much greater than for the relational world.

Users should be happy to not have this functionality... ;-)

Henrik

LinkWithin

Related Posts with Thumbnails