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

Re: limits of the generic

pinning algorithm
Hi Jeff,

> It seems there's something wrong with the pinning algorithm.
> Probably, there should be an attempt to do pinning only at the end
> of the computation (by analogy with rounding) -- the idea of pinning
> to a valid date after adding Y/M components, then later dealing with
> the day and time parts seems of dubious merit.

Agreed that it's something wrong with the pinning algorithm, but I
don't think that leaving the pinning until the end works either.
We're trying to find an algorithm where following is true:

  2004-01-29T12:00:00 + P1M  <

  2004-01-30T00:00:00 + P1M  <

  2004-01-30T12:00:00 + P1M  <
  2004-01-31T00:00:00 + P1M  <

  2004-01-31T12:00:00 + P1M  <
  2004-02-01T00:00:00 + P1M

It seems obvious that 2004-01-29T12:00:00 + P1M => 2004-02-29T12:00:00
and that 2004-02-01T00:00 => 2004-03-01T00:00:00. Which means that we
need to find something where the following is true:

  2004-02-29T12:00:00  <

  2004-01-30T00:00:00 + P1M  <

  2004-01-30T12:00:00 + P1M  <
  2004-01-31T00:00:00 + P1M  <

  2004-01-31T12:00:00 + P1M  <

And now things are difficult, to say the least. If the days are pinned
back then 2004-01-29T12:00:00 + P1M < 2004-01-30T00:00:00 + P1M
won't be true. If they're rounded up, then 2004-01-31T12:00:00 + P1M <
2004-02-01T00:00:00 + P1M won't be true. In either case, keeping the
relationship 2004-01-30T12:00:00 + P1M < 2004-01-31T00:00:00 + P1M is
going to be hard.

It's not just a matter of the times causing problems, or that it's a
leap year causing the difficulty. There are similar issues with:

  2002-01-28 + P1M  <

  2002-01-29 + P1M  <

  2002-01-30 + P1M  <

  2002-01-31 + P1M  <

  2002-02-01 + P1M

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:

    xs:date('2002-01-28'), xs:yearMonthDuration('P1M')) <
    xs:date('2002-01-30'), xs:yearMonthDuration('P1M'))



Jeni Tennison


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.
First Name
Last Name
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.