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 4471 - [FO] Casting date/time timezone offset 0 values to string/untypedAtomic
Summary: [FO] Casting date/time timezone offset 0 values to string/untypedAtomic
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows XP
: P1 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: 2007-04-18 19:07 UTC by Michael Rys
Modified: 2007-11-16 09:14 UTC (History)
0 users

See Also:


Attachments

Description Michael Rys 2007-04-18 19:07:24 UTC
The current casting rules for values of date/time type with timezone offset 0 values to string/untypedAtomic generate the serialization +00:00 instead of the shorter and much more often used Z. Note that all the examples in the document normally use Z instead of +00:00 and a few existing implementations also use Z (Saxon, SQL Server).

We therefore request that the casting rules get changed to produce a Z instead.

Searches in the old documents appear to have moved from the rule (last seen in http://www.w3.org/TR/2005/WD-xpath-functions-20050211/)

<cite>If necessary, the localized value is recovered from the normalized value as follows: if an explicit timezone was present, the normalized value is adjusted using the explicit timezone; if an explicit timezone was not present, the Z timezone is dropped from the normalized value. The localized value and the explicit timezone, if present, are cast separately to xs:string and concatenated to yield TV.</cite>

which seem to imply to work with Z, to the current rule... since this was an editorial rework and after talking to the editors, we assume that this was an oversight.

This will also affect the data model serialization.
Comment 1 Michael Kay 2007-04-23 21:37:30 UTC
Note also, although QT has departed from the definitions in XML Schema as regards timezone preservation, the canonical representation in XML Schema does denote UTC by "Z", and there is no reason why we should choose to differ from this.
Comment 2 Michael Kay 2007-05-01 21:46:37 UTC
Proposed change: in 17.1.5 Casting to Date and Time Types, change

declare function eg:convertTZtoString($tz as xs:dayTimeDuration?) as xs:string
{
   if (empty($tz)) then ""
   else 
     let $tzh := fn:hours-from-dayTimeDuration($tz)
     let $tzm := fn:minutes-from-dayTimeDuration($tz)
     let $plusMinus := if ($tzh >= 0) then "+" else "-"
     let $tzhString := eg:convertTo2CharString(fn:abs($tzh))
     let $tzmString := eg:convertTo2CharString(fn:abs($tzm))
     return fn:concat($plusMinus, $tzhString, ":", $tzmString)
}

to

declare function eg:convertTZtoString($tz as xs:dayTimeDuration?) as xs:string
{
   if (empty($tz)) 
     then ""
   else if ($tz eq xs:dayTimeDuration('PT0H'))
     then "Z"
   else 
     let $tzh := fn:hours-from-dayTimeDuration($tz)
     let $tzm := fn:minutes-from-dayTimeDuration($tz)
     let $plusMinus := if ($tzh >= 0) then "+" else "-"
     let $tzhString := eg:convertTo2CharString(fn:abs($tzh))
     let $tzmString := eg:convertTo2CharString(fn:abs($tzm))
     return fn:concat($plusMinus, $tzhString, ":", $tzmString)
}
Comment 3 Michael Kay 2007-05-18 10:32:06 UTC
The proposed change was accepted in the joint meeting 329 on 2007-05-08, with one minor change: the zero-length duration should be expressed in its canonical form as PT0S.

The change will appear as erratum FO.E6
Comment 4 Michael Kay 2007-06-12 20:17:25 UTC
I am reopening this bug because of an unrelated error in the same function. Both the original and the "corrected" versions of the internal function eg:convertTZtoString use the functions fn:hours-from-dayTimeDuration and fn:minutes-from-dayTimeDuration, which no longer exist. The functions are now called fn:hours-from-duration and fn:minutes-from-duration.

The collective eyeballs of the WG seem to have been out of focus...
Comment 5 Michael Kay 2007-06-27 14:54:55 UTC
The WGs approved this change on 27 June 2007