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 ]


I think you've hit the nub of this issue.  We expect '+' to be commutative,
associative, and have additive inverses.  At least associativity and
additive inverses have been shown in the examples in this thread to have
been violated when dates and one or more durations are added.  We also
expect consequences of these properties, such as
    a + x = a + y   => x = y
    x < y => x + a < y + a
(where a is a duration and x and y are dates) to be true, and they are not
(the converse of the first one is true, however).  The algebra of DateTime x
Duration with operation + is not the algebra of a group or any other
familiar structure, so many of our expectations for the '+' operation will
be violated.  Typically this is occuring because a thing that looks like a
fixed duration, such as P1M, is actually a different length in units of days
or seconds depending upon the context in which it is used in addition.

As you say, however, it is useful to be able to add and subtract dates and
durations.  If someone with a decent background in algebra can spell it out
formally, there may be some way for people to use '+' and not have their
intuition violated too often.  Otherwise, (or perhaps even if there is a
formal algebra, but it's too exotic) treating the addition as a named
function with arbitrary but reasonable semantics, without all the
assumptions about '+' that we drag into every addition we see, may be the
right way to proceed.

----- Original Message -----
From: "Jeni Tennison" <jeni@jenitennison.com>
To: "Jeff Greif" <jgreif@alumni.princeton.edu>
Cc: <xml-dev@lists.xml.org>
Sent: Monday, September 30, 2002 4:27 AM
Subject: Re: [xml-dev] limits of the generic

> Hi Jeff,
> Hmm... The thing is that adding durations to date/times is a useful
> thing to do, so I'd be loath to make it impossible in XPath 2.0. If it
> were done through a function call instead, that would enable the +
> operator to retain its usual semantics. What do you think? Would it
> matter if:
>   2002-01-28  <  2002-01-30
> but not:
>   add-yearMonthDuration-to-date(
>     xs:date('2002-01-28'), xs:yearMonthDuration('P1M')) <
>   add-yearMonthDuration-to-date(
>     xs:date('2002-01-30'), xs:yearMonthDuration('P1M'))


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

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