[xquery-talk] XQuery and Item Orientation

Hans-Juergen Rennau hrennau at yahoo.de
Tue Jan 20 07:46:48 PST 2009

Hello People,

I would like to learn about your thoughts about a perspective of introducing "item orientation" - an echo of object orientation - into XQuery.

Starting point: in my opinion, software development has undergone two revolutions: object orientation, and XML/XPath/XQuery, both acting as reducers of complexity. Suddenly it appears strange to me that XQuery makes no attempt to incorporate object oriented features. More concretely, I think of binding functionality to a) type and b) instance. Imagine a second kind of function were introduced into the language, call it itemFunction, which is invoked like an object's member function, where the "object" is an item:

Within the function body, the item is available as the context item expression (its top level uses, of course). So much for the binding to an instance. Now the binding to a type. This amounts to some sort of test used to select the appropriate function definition for a given item. An obvious possibility were to bind function declarations to an item type which must be matched by the item on which the function is invoked, for example thus:
   declare itemFunction element(tringle) local:rotate() {...}
   declare itemFunction element(square, squareType) local:rotate() {...}

More flexibility is gained by the additional possibility to specify an item test in the form of an XPath expression:
   declare itemFunction element(), itemTest="@geometrical eq true()" 
               element(tringle, triangleType) local:rotate() {...}

To demonstrate the simplicity to be gained, imagine the task to edit a sequence of reports for rendering purposes. You might write

and start with a default implementation of the itemFunction 'render'. Later, you refine the rendering by simply *adding* special versions, and you can even do so by just importing additional modules.

My questions to you:
- would such extensions of XQuery be desirable (from the user's point of view)
- would such extensions introduce drawbacks or problems (from the implementor's point of view)

Thank you for any comments!
Hans-Juergen Rennau


More information about the talk mailing list