OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] limits of the generic

[ Lists Home | Date Index | Thread Index ]

--- Jeni Tennison <jeni@jenitennison.com> wrote:
> 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.

Our devs actually opposed this since it gives
xs:duration an air of legitimacy and people start to
ask why they can't do other things with it (in much
the same manner you are doing now). 
> 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:

I question your usage of the term "perfectly
legitimate". The mixing of years, months and days in a
single duration type leads to indeterminate order
relationships at several points which means that the
type is partially ordered. More information about this
is available in the W3C XML Schema Datatypes

> 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

Did you write this with a straight face? A type that
allows (A < B, A = B, A > B) to all return the same
value is confusing to end users and rather unuseful.
Also it is a significant, hard-to-find bug waiting to
happen in someone's application. 

> We could introduce three-value logic:
>   P3M = P90D  =>   ()
>   P3M > P90D  =>   ()
>   P3M < P90D  =>   ()

So how would you sort the following durations  P13M,
P3M, P91D, P367D, P365D, P90D, P89D, and P12M given
your 3-valued logic? 

> 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

Why is a A + 3M greater than A + 90D? The 3 months
range consisting of January (31d), February (28d), and
March (31d) is exactly 90 days long. I guess noone is
expected to use this type for anything requiring
accuracy or correct results then? 

> 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.

*cough* Hack *cough* 

> 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.

It isn't a well defined question. Is the year a
regular year or a leap year? 

On the other hand "what is 2002-09-28 plus 366 days?" 
is a simple question with a well defined answer which
is possible in XPath 2.0

[0] http://www.w3.org/TR/xmlschema-2/#duration

I will never build a sentient computer smarter than I am.

Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS