[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath 2.0 - how much of XQuery should it include?


xpath ternary operator
Bah, you're right of course.  Good illustration of why I should stay out of this thread until I have enough time to properly consider my contributions.  I'm not at all sure what I was thinking of.

> Uche wrote:
> > I agree with most of your post Jeni. The one thing that would be
> > nice to see introduced into XPath is some sort of shortcutting in
> > certain operators (either the boolean operators, or with an
> > introduced ternary operator). XPath 2.0's if expressions provide
> > this. If course, short-cutting is really much nicer and safer in a
> > side-effect-free language, so XPath 2.0 manages to chuck this
> > advantage as well.
> 
> "Shortcutting" means that you only evaluate the first part of the
> expression if you can determine the result of the expression, correct?
> In XPath 1.0, 'and' and 'or' are shortcutting:
> 
>   An or expression is evaluated by evaluating each operand and
>   converting its value to a boolean as if by a call to the boolean
>   function. The result is true if either value is true and false
>   otherwise. **The right operand is not evaluated if the left operand
>   evaluates to true.**
> 
>   An and expression is evaluated by evaluating each operand and
>   converting its value to a boolean as if by a call to the boolean
>   function. The result is true if both values are true and false
>   otherwise. **The right operand is not evaluated if the left operand
>   evaluates to false.**
> 
> I hadn't noticed that this changes in XPath 2.0 (it's not listed as
> one of the incompatibilities):
> 
>   The order in which the operands of a logical expression are
>   evaluated is implementation-dependent. The tables above are defined
>   in such a way that an or-expression can return true if the first
>   expression evaluated is true, and it can return the error value if
>   the first expression evaluated contains an error. Similarly, an
>   and-expression can return false if the first expression evaluated is
>   false, and it can return the error value if the first expression
>   evaluated contains an error.
> 
> Basically, implementations are free to implement it as a shortcut, or
> free not to. Which means that anyone who has taken advantage of the
> shortcutting in XPath 1.0, or who takes advantage of the shortcutting
> available in a particular implementation of XPath 2.0, is likely to
> run into problems. For example, if someone has:
> 
>   function-available('my:boolean-function') and my:boolean-function()
> 
> then they might now get an error where they didn't before. If someone
> has:
> 
>   *[simple-filtering-expression or complex-filtering-expression]
> 
> then their performance might be hit.
> 
> I agree completely that something similar to the if expression in
> XPath 2.0 is required. I don't like if/then/else because it encourages
> people to use XPath 2.0 as a language in its own right, but I'd rather
> have that than no conditional expression at all.


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Track chair, XML/Web Services One (San Jose, Boston): http://www.xmlconference.com/
DAML Reference - http://www.xml.com/pub/a/2002/05/01/damlref.html
The Languages of the Semantic Web - http://www.newarchitectmag.com/documents/s=2453/new1020218556549/index.html
XML, The Model Driven Architecture, and RDF @ XML Europe - http://www.xmleurope.com/2002/kttrack.asp#themodel


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.