[Bug 24511] Function item and maps, error situations or side effects

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

--- Comment #3 from Abel Braaksma <abel.braaksma@xs4all.nl> ---
Maybe I misunderstand maps, but I thought the following is possible:

<xsl:variable name="m" as="map(xs:string, xs:boolean)" select="lang#1" />
<xsl:value-of select="map:keys($m)" />

Reason why I think it is possible is that the type of lang#1 is
function(xs:string?) as xs:boolean. Testing it with our own processor and with
Saxon gives an error that the types are not compatible, perhaps because of the
cardinality of the argument of fn:lang.

Similarly, I would say that the following holds:

<xsl:function name="f:test" as="item()*">
    <xsl:param name="a" as="xs:anyAtomicType" />
    <xsl:value-of select="'test'" />
</xsl:function>

<xsl:variable name="m" as="map(xs:anyAtomicType, item()*)" select="f:test#1" />
<xsl:value-of select="map:keys($m)" />

But again, both Exselt and Saxon raise (probably correctly?) an error here.
Reading up in the spec I find the following:

"The function signature of the map, treated as a function, is always
function(xs:anyAtomicType) as item()*, regardless of the actual types of the
keys and values in the map."

If that is true, even if the type of map is specified, then it is
understandable why the first example above doesn't hold (return type is
covariant). But the second example seems compatible with the function type in
the sense that:

map(xs:anyAtomicType, item()*) instance of function(xs:anyAtomicType) as
item()*

and:

function(xs:anyAtomicType) as item()* instance of map(xs:anyAtomicType,
item()*) 

More precisely, the spec says a lot about using the function coercion rules
from map to function, but leaves out the coercion from function to map. In the
subtype relationships this is not mentioned (under 21.1.1, last paragraph), but
perhaps (and that is a misunderstanding from my end), on purpose: it only shows
that function(*) and function(xs:anyAtomicType) as item()* are subtypes of
map(*).

@Innovimax: I didn't mean a function as a value of a map, but a function item
as a map.

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

Received on Wednesday, 5 February 2014 17:04:01 UTC