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 1512 - editorial suggestion for fn:min and fn:max
Summary: editorial suggestion for fn:min and fn:max
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Last Call drafts
Hardware: All All
: P2 minor
Target Milestone: ---
Assignee: Ashok Malhotra
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-29 14:03 UTC by Joanne Tong
Modified: 2007-02-25 23:40 UTC (History)
0 users

See Also:


Attachments

Description Joanne Tong 2005-06-29 14:03:08 UTC
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
Comment 1 Ashok Malhotra 2005-07-01 14:07:28 UTC
Thank you, Joanne!  I have clarified the wording for fn:min and fn:max taking
your suggestions into account.
Comment 2 Jim Melton 2007-02-25 23:40:16 UTC
Closing bug because commenter has not objected to the resolution posted and more than two weeks have passed.