This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 5717 - [F&O] Definition of op:divide-dayTimeDuration-by-dayTimeDuration and op:divide-yearMonthDuration-by-yearMonthDuration
Summary: [F&O] Definition of op:divide-dayTimeDuration-by-dayTimeDuration and op:divid...
Status: CLOSED WONTFIX
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-27 09:51 UTC by Oliver Hallam
Modified: 2008-06-23 09:21 UTC (History)
0 users

See Also:


Attachments

Description Oliver Hallam 2008-05-27 09:51:44 UTC
op:divide-dayTimeDuration-by-dayTimeDuration is defined as follows [F&O 10.6.9]:

Summary: Returns the result of dividing the value of $arg1 by $arg2. Since the values of both operands are decimals, the semantics of the division is identical to op:numeric-divide with xs:decimal operands.


and here is the definition of op:divide-yearMonthDuration-by-yearMonthDuration [F&O 10.6.5]:

Summary: Returns the result of dividing the value of $arg1 by $arg2. Since the values of both operands are integers, the semantics of the division is identical to op:numeric-divide with xs:integer operands.


There is no reason that the implementation defined limits on xs:dayTimeDuration fall within the implementation defined limits of xs:decimal; similarly for xs:yearMonthDuration.

Although it is obvious how a dayTimeDuration can be viewed as a decimal this is never explained anywhere in the document, and the phrase "since the values of both operands are decimals" is wrong.

Does this also imply that the errors raised are those raised by op:numeric-divide (ie FOAR0002 for overflow, instead of FODT0002)?

It does seem rather odd that dividing a dayTimeDuration by xs:double(0) return an FODT0002, but dividing a dayTimeDuration by xs:dayTimeDuration("P0S") returns an FOAR0001.
Comment 1 Michael Kay 2008-06-04 16:50:09 UTC
For the time being this is a personal response - but it's also my formal response to an action by the WG to prepare a response for them to consider.

Firstly, I think that sections 10.3.1 and 10.3.2 do explain, perhaps not very elegantly, how the values of a yearMonthDuration and a dayTimeDuration can be considered to be an xs:integer and an xs:decimal respectively. Indeed, for yearMonthDuration it goes so far as to say that the value IS an xs:integer, and this justifies the phrase in 10.6.5 "the values of both operands are integers". For dayTimeDuration it says "The value space of xs:dayTimeDuration is the set of fractional second values." and I think the author was clearly considering that it was therefore a set of xs:decimal values.

Also, section 10.1.1 says: "The value spaces of the two totally ordered subtypes of xs:duration described in 10.3 Two Totally Ordered Subtypes of Duration are xs:integer months for xs:yearMonthDuration and xs:decimal seconds for xs:dayTimeDuration. "

I think this could perhaps be expressed better, but I don't think it's sufficiently wrong to justify an erratum.

>>There is no reason that the implementation defined limits on xs:dayTimeDuration fall within the implementation defined limits of xs:decimal; similarly for xs:yearMonthDuration.

Correct, I don't think the spec suggests that this is the case.

>Although it is obvious how a dayTimeDuration can be viewed as a decimal this is
never explained anywhere in the document, and the phrase "since the values of
both operands are decimals" is wrong.

I think it's explained in the sections cited above.

>Does this also imply that the errors raised are those raised by
op:numeric-divide (ie FOAR0002 for overflow, instead of FODT0002)?

No, I think the error on overflow is as stated in section 10.1.1.

There's a significant editorial problem with the F+O spec in that readers turn to the specifications of individual functions, and fail to find the mass of information in the general introductory sections. I would like to make the function specifications more self-contained by including references to the general sections that are relevant. But that's not something to be tackled by erratum.

>>It does seem rather odd that dividing a dayTimeDuration by xs:double(0) return
an FODT0002, but dividing a dayTimeDuration by xs:dayTimeDuration("P0S")
returns an FOAR0001.

I agree, treating divide by zero as equivalent to overflow seems a curious design choice. But it's not a bug.

So my proposal is, that despite the fact that you have uncovered some inelegancies in both the design and the exposition, that we decline to make any change to the 1.0 specification.

Michael Kay

Comment 2 Michael Kay 2008-06-10 15:31:43 UTC
The WG discussed this on 10 June 2008. We'll leave it open for the time being to give Oliver a chance to respond, but the current sentiment is to concur with comment #1.
Comment 3 Michael Kay 2008-06-23 09:20:28 UTC
In view of the lack of any pushback, the WG decided to close this with no action.