Re: [xsl] Required cardinality checks

Subject: Re: [xsl] Required cardinality checks
From: Pavel Minaev <int19h@xxxxxxxxx>
Date: Wed, 30 Sep 2009 15:05:06 -0700
On Wed, Sep 30, 2009 at 2:47 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> These rules have led to a great deal of debate, and there is certainly room
> for different interpretations. Note also that there are a number of
> published errata in this area. However, the sentence
>
>>If a processor evaluates an operand E (wholly or in part), then it is
> required to establish that the actual value of the operand E does not
> violate any constraints on its cardinality.
>
> was carefully written: the implication is that if the processor does not
> evaluate E, then it is NOT required to check the cardinality of E.

This makes sense, but there are some less obvious cases where it is
still not clear how the above would apply. For example:

    <xsl:function name="my:foo">
        <xsl:param name="xs" as="xs:integer"/>
        <xsl:value-of select="$xs[1]"/>
    </xsl:function>

And a call:

    my:foo((1, 2))

or even:

    my:foo(())

Common sense tells me that the second one should definitely trigger an
error (because the user is entitled to expect that $xs[1] should never
produce an empty sequence), but I'm not sure about the first one -
eliding a check there doesn't seem like it would have any undesirable
effect "down the line", so to speak, so why not?

Current Thread