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

Re: limits of the generic


xs duration
Hi Dare,

> xs:duration is broken and should never have made it into the W3C XML
> Schema REC in the first place. Simple question; Is an xs:duration
> representing 3 months equivalent to an xs:duration representing 90
> days?

According to the latest XPath 2.0 F&O WD, you can actually do
xs:duration('P3M') = xs:duration('P90D') and if they're not "exactly
equal" the answer is false.

But I think that you're getting at the fact that it's undefined. I can
think of several ways of dealing with that which don't rule out
perfectly legitimate uses of durations that mix years or months and
days or times:

We could simply say that if it's undefined it's false (though I
believe that this leads to optimisation problems because it means that
it's no longer true that a values must be one of equal, greater than
or less than another value):

  P3M = P90D  =>   false
  P3M > P90D  =>   false
  P3M < P90D  =>   false

We could introduce three-value logic:

  P3M = P90D  =>   ()
  P3M > P90D  =>   ()
  P3M < P90D  =>   ()
  
We could ban direct comparisons of durations, forcing users to add
them to dates in order to compare them:

  2002-09-28 + P3M = 2002-09-28 + P90D  =>  false
  2002-09-28 + P3M > 2002-09-28 + P90D  =>  true
  2002-09-28 + P3M < 2002-09-28 + P90D  =>  false

Or we could use the current date/time automatically in a comparison
like the above. Or we could pick a date in the past and use that
consistently for all duration comparisons.

Any of these would be better than making it an error for people to ask
perfectly legitimate, and answerable, questions and introducing two
new, more restrictive, data types that users have to use instead of
xs:duration in order for their schemas to work with XPath 2.0. For
example, I think that "What is 2002-09-28 plus a year and a day?" is
also a simple question with a well-defined answer; I don't think it
should be an error to try to ask it.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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.