Having glanced through most XQuery books and countless general XQuery articles, most go out of their way to say that XQuery supports SQL’s SELECT, FROM and WHERE capabilities. This may be true for the SQL FROM and WHERE operations, but certainly is not true for the powerful SQL SELECT list operation.
The WHERE clause in SQL is basically identical to its use in XQuery and the FROM clause in SQL is similar to the input capability used in the XQuery LET and FOR operation. But where is the SELECT list operation in XQuery?
The SELECT list in SQL specifies which data items in the query are to be output. There is no one isolated specification of output data items in XQuery. In XQuery, each output item has to be specifically controlled in the processing logic. This processing logic usually consists of multiple nested hierarchical loop logic, so the placement of each data item that will be output has to done carefully and possibly separately for each data item. So adding or removing an output item takes manual programming and testing. In some cases adding an output data item will require programming an additional hierarchical nested loop level. With SQL, adding or removing an output item is just as easy as adding or removing an output item from the SELECT list which can be done dynamically at view invocation and requires no additional procedural program logic.
With SQL’s nonprocedural and navigationless access and processing, it is possible to automatically perform the processing driven by what data items are listed in the SELECT list. By knowing what data items are to be output, their access and processing is automatically performed utilizing only the hierarchical pathways necessary and the output data items are automatically formatted according to their dynamic runtime hierarchical data structure. These are both controlled effortlessly through the SQL dynamic SELECT list making it an extremely powerful operation.
XQuery has no automatic equivalent or similar operation that can dynamically accommodate the simple adding and removing of output data items. This is not to say that this capability can’t be performed in XQuery. It can be programmed into the XQuery program logic so that the user can switch output items on and off at runtime invocation to control dynamic processing and output.This does require extra programming and is limited to only the switching capabilities that have been programmed in advance of operation. To program all output combinations with their optimized processing would be a monumental task.