[xquery-talk] XQuery and Item Orientation

Hans-Juergen Rennau hrennau at yahoo.de
Fri Jan 30 07:16:31 PST 2009


Hello Ghislain,

you wrote:

"The mapping ..(based on)... patterns with user-defined priority (as an alternative  
to type hierarchies for polymorphism) is interesting. I have questions  
regarding this: with this approach, what kind of control would an  
implementor/a user have about which function is called when? How would  
this affect predictability of program execution and debugging? Does  
XQuery not already have some kind of type-hierarchy-based polymorphism  
(the recommendation says in 3.1.5. (Function Calls) "the rules for  
SequenceType Matching permit a value of a derived type to be  
substituted for a value of its base type")?

My suggestion to follow the approach taken by XML Schema 1.1 when selecting a type alternative - rather than the (powerful but less lucid) approach taken (for good reasons) by XSLT, that is:

~ XML Schema 1.1's type selection: 
"associate an ordered list of type alternatives with test expressions; the first match is taken!"

~ item orientation: 
"associate an ordered list of function variants with test expressions; the first match is taken!"

(It is is a minor detail on how to organize this "list" of functions
syntactically (explicitly, or implicitly by order of function declarations and imports.)

The predictability would of course be the same as with XML Schema - total. But perhaps I should point out one difference between your approach and mine (if I understood you correctly): you chose to make any function call potentially an item function call, with the current context item providing the "candidate item". You wrote:
   $triangle/rotate()
whereas I prefer to make item calls explicit:
   $triangle/.->rotate()

This does play a role in terms of lucidity, dont't you think?

With kind regards -
Hans-Juergen Rennau


~~~~


Hello,

I think that it is an important point that the relevance of object- 
orientation features in XQuery depends on the use cases. Everybody (I  
think) agrees that XQuery is very efficient and well-suited to process  
XML/relational data: it was designed exactly for this. The question  
here seems to be: can XQuery do more, e.g., do what Java/C++ do --  
without reducing performance on pure XML processing -- and would this  
be desirable at all?

My feeling is that XQuery has a considerable potential. As Hans- 
Juergen Rennau mentioned it earlier, XQuery/XML/XPath was one of two  
major revolutions in software development, the other being object- 
oriented programming, and so I am also wondering: would it not be nice  
and useful if one were able to design a seamless (i.e., XML nodes and  
objects are "the same") solution cumulating the best sides of both XML  
Querying and Object-orientation in a single language? Would not XQuery  
be a good match for this?

The mapping suggested by Hans-Juergen Rennau following Michael Kay's  
comment about patterns with user-defined priority (as an alternative  
to type hierarchies for polymorphism) is interesting. I have questions  
regarding this: with this approach, what kind of control would an  
implementor/a user have about which function is called when? How would  
this affect predictability of program execution and debugging? Does  
XQuery not already have some kind of type-hierarchy-based polymorphism  
(the recommendation says in 3.1.5. (Function Calls) "the rules for  
SequenceType Matching permit a value of a derived type to be  
substituted for a value of its base type")?

Kind regards and thanks a lot for your interesting comments,
Ghislain Fourny



************************************



      



More information about the talk mailing list