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 3718 - fn:index-of
Summary: fn:index-of
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
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: 2006-09-13 14:26 UTC by Tim Mills
Modified: 2007-02-25 23:34 UTC (History)
0 users

See Also:


Attachments

Description Tim Mills 2006-09-13 14:26:38 UTC
The summary of this function does not describe how to compare values of type xs:untypedAtomic.

In contrast, fn:distinct-values says "Values of type xs:untypedAtomic are compared as if they were of type xs:string."  There are similar phrases covering fn:sum, fn:min, fn:max and fn:avg.

Should this phrase be added to fn:index-of?
Comment 1 Michael Kay 2006-09-13 15:01:30 UTC
I think the phrase:

The items in the sequence $seqParam are compared with $srchParam under the rules for the eq operator

makes it unambiguous.

Michael Kay (personal response)
Comment 2 Tim Mills 2006-09-13 15:37:24 UTC
Fair point.  The reason we came across this was because under the Formal Semantics normalization  for function calls, we get:

fn:index-of($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType)

fn:index-of(
  fs:convert-simple-operand(
    fs:data($seqParam as xs:anyAtomicType*),
    PrototypicalValue(xs:anyAtomicType))
  fs:convert-simple-operand(
    fs:data($srchParam as xs:anyAtomicType*)),
    PrototypicalValue(xs:anyAtomicType)))

I haven't found a definition for the PrototypicalValue for xs:anyAtomicType.  (The spec does define it as an xs:double for numeric arguments).

Our resolution has been to choose the PrototypicalValue based on whether we are dealing with avg, min, max, sum (treat as xs:double) or index-of, distinct-values (treat as xs:string).
Comment 3 Jerome Simeon 2006-09-19 16:39:11 UTC
I think I agree with both Tim and Michael, if they allow me. The fact that the definition relies on eq makes it unambiguous. i.e., xs:untypedAtomic gets cast to xs:string. It would be worth spelling it out explicitely as all other functions do (fn:index-of seems to be quite similar to fn:distinct-values to that respect). So using xs:string for the PrototypicalValue as Tim suggests in his last comment is the right thing to do here.
- Jerome
Comment 4 Jim Melton 2007-02-25 23:34:32 UTC
Closing bug because commenter has not objected to the resolution posted and more than two weeks have passed.