[Bug 1512] New: editorial suggestion for fn:min and fn:max

http://www.w3.org/Bugs/Public/show_bug.cgi?id=1512

           Summary: editorial suggestion for fn:min and fn:max
           Product: XPath / XQuery / XSLT
           Version: Last Call drafts
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Functions and Operators
        AssignedTo: ashok.malhotra@oracle.com
        ReportedBy: joannet@ca.ibm.com
         QAContact: public-qt-comments@w3.org


What should be the result of evaluating the following XPath expression? 

fn:max((xs:integer('10'), xs:float('1'))) instance of xs:integer 

     The description of fn:max says that it "Selects an item from the input 
sequence $arg whose value is greater than or equal to the value of every other 
item in the input sequence."  It goes on to say that "For numeric values, the 
numeric promotion rules defined in 6.2 Operators on Numeric Values are used to 
promote all values to a single common type."  Does the function return the 
promoted value that is greatest, or does it return the item from the original 
sequence whose promoted value is greatest? 

     The following example appears under fn:min.  It seems to indicate that the 
promoted value should be returned, but so far as I can tell, the descriptions 
of fn:min and fn:max don't state that explicitly. 

fn:min((5, 5.0e0)) returns 5.0e0 

     I believe the intention of the WG is to return the promoted value, and 
that the description of fn:min and fn:max should be clear that an item from the 
converted sequence (instead of the input sequence) should be returned.  I also 
noticed that the rules listed in the description of fn:max are disorganized.  I 
suggest the following replacement text for fn:max (and similarly for fn:min) 
starting from the second paragraph to the link 7.3.1 Collations.

---------------------------------------------------------- 

The following rules may be applicable to the input sequence.  If a resulting 
sequence exists after applying these rules, then it is referred to as the 
converted sequence.  This function would then return an item from the converted 
sequence rather than the input sequence.  The items in the converted sequence 
may be reordered in an arbitrary order. 

·    Any values of type xdt:untypedAtomic in the input sequence $arg are cast 
to xs:double. 
·    For numeric values, the numeric promotion rules defined in 6.2 Operators 
on Numeric Values are used to promote all values to a single common type. 
·    Duration values must either all be xdt:yearMonthDuration values or must 
all be xdt:dayTimeDuration values. 
·    All items in $arg must be numeric or derived from a single base type for 
which the gt operator is defined. In addition, the values in the sequence must 
have a total order.   
·    If any of these conditions is not met, then a type error is raised 
[err:FORG0006]. 

In addition, the following rules may be applicable to the input or converted 
sequence: 

·    If the sequence is empty, the empty sequence is returned. 
·    If date/time values do not have a timezone, they are considered to have 
the implicit timezone provided by the dynamic context for purposes of 
comparison. 
·    If the sequence contains the value NaN, the value NaN is returned. 
·    If the items in the value of $arg are of type xs:string or types derived 
by restriction from xs:string, then the determination of the item with the 
largest value is made according to the collation that is used. If the type of 
the items in $arg is not xs:string and $collation is specified, the collation 
is ignored. 
·    The collation used by the invocation of this function is determined 
according to the rules in 7.3.1 Collations. 

... 

---------------------------------------------------------- 

Thanks,
Joanne

Received on Wednesday, 29 June 2005 14:03:12 UTC