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

RE: XML design of ((a and b) or c)

  • From: "Michael Kay" <mike@s...>
  • To: "'Rick Marshall'" <rjm@z...>,"'Ken North'" <kennorth@s...>
  • Date: Fri, 15 Dec 2006 11:35:10 -0000

RE:  XML design of ((a and b) or c)
> However the other side effect is also interesting and 
> important - the ability to not evaluate something once a 
> condition has been determined (or  indeed force evaluation). 
> At the moment I believe XSLT is required for that.

I'm glad someone brought the discussion back to XML.

In XPath 1.0 the "and" operator has short-cut semantics: given (A and B), B
is not evaluated if A is false. However, it's almost impossible to write
code that depends on this, because (1) evaluating A cannot have any
side-effects that influence the evaluation of B, and (2) there are very few
expressions in XPath 1.0 that can cause dynamic errors.

In the new round of specs this has changed so that the order of evaluation
of arguments is explicitly implementation-dependent. The reason for this is
to allow optimization of predicates (and where clauses in XQuery) to use
indexes: given //x[age < 100 and name="Snelsdon"] you want to be able to use
an index on name if one is available. This means you can't safely use the
first condition to mask errors that might occur in the second, as in

//x[(y castable as xs:integer) and (xs:integer(y) > 100)]

Instead you have to write:

//x[if (y castable as xs:integer) then (xs:integer(y) > 100) else false()]

In fact, you can't even safely write 

//x[y castable as xs:integer][xs:integer(y) > 100]

(I won't try to defend that decision)

Michael Kay
http://www.saxonica.com/



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.