[Bug 27059] New: [xp3.1] Function coercion, maps and arrays

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27059

            Bug ID: 27059
           Summary: [xp3.1] Function coercion, maps and arrays
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XPath 3.1
          Assignee: jonathan.robie@gmail.com
          Reporter: mike@saxonica.com
        QA Contact: public-qt-comments@w3.org

Although the spec is probably technically correct, it would be worth some
explanation of how function coercion interacts with maps and arrays.

Firstly, if the expected type is a map or array type, then function coercion
does not apply. That's because the expected type is not [written as a]
TypedFunctionTest (bullet 3 of 3.1.5.2). Note that the bullets here are rather
varied in style, for example:

"If the expected type calls for a single item or optional single item"
"If the expected type is xs:string or xs:string?"
"If the expected type is a sequence of a generalized atomic type"

It would be better if they were all phrased in terms of how the type is
expressed syntactically.

Secondly, if the expected type is (expressed as) a TypedFunctionTest, and the
actual supplied value is a map or array, then function coercion does apply. For
example, fn:sort expects a function item of type function(item()) as
xs:anyAtomicType*, and it is acceptable to supply a map as the value of this
argument. If a map $M is passed, the rules of function coercion say that this
is equivalent to passing the function

function($key as item()) as xs:anyAtomicType* {
  $M($key)
}

which in general (unless there is an atomization failure) will work; the sort
key for any value not present in the map is an empty sequence.

It's certainly worth a note or an example to explain this.

Thirdly, if the expected type is written as function(*), then it is legal to
supply a map or array as the value of the argument, but no coercion takes
place.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 15 October 2014 14:57:32 UTC