[xquery-talk] xs:error and AbstractTypes
Adam Retter
adam.retter at googlemail.com
Sun Jan 13 04:01:00 PST 2019
Thanks Mike :-)
On Sun, 13 Jan 2019 at 18:41, Michael Kay <mike at saxonica.com> wrote:
>
> xs:error is defined in XSD 1.1 part 1:
>
> [Definition:] A special simple type definition, whose name is error in the XSD namespace, is also present in each ·XSD schema·. The XSD error type has no valid instances. It can be used in any place where other types are normally used; in particular, it can be used in conditional type assignment to cause elements which satisfy certain conditions to be invalid.
>
> In §3.16.7.3 it is defined as a union type with no member types.
>
> I think that this call should fail on the grounds that () is not a valid instance of xs:error.
>
> What's happening is apparently that when xs:error is used as a SequenceType, it is given a required cardinality of 0, and the type matching, when it sees a required cardinality of 0, allows an empty sequence to appear. I think the correct handling would be to have a required cardinality of 1.
>
> Raised at https://saxonica.plan.io/issues/4091
>
> Michael Kay
> Saxonica
>
> On 12 Jan 2019, at 09:22, Adam Retter <adam.retter at googlemail.com> wrote:
>
> Whilst looking for a type which is declarable in XQuery but that
> cannot be constructed, I wrote a strange query, well to me anyway,
> which evaluates on Saxon 9.8.0.12 PE, and returns <hello/>.
>
> declare function local:test1($x as xs:error) {
> <hello/>
> };
> local:test1(())
>
> You can also modify the query so the parameter has one-or-mode
> cardinality e.g. "$x as xs:error+", and it will still evaluate with an
> empty sequence as the argument. I believe that this is because
> xs:error is always an empty type.
>
> BaseX and eXist-db both refuse to evaluate the query, saying that the
> type xs:error is unknown.
>
> Am I right in thinking that Saxon evaluates this because it supports
> [Schema 1.1 Part 2], whereas eXist-db and BaseX do not?
>
> Also if anyone has any bright ideas, about a type that I could
> explicitly declare for a function argument, but that CANNOT be
> constructed within XQuery, I would be interested to know. I think
> Union types are out as I want to support all processors (i.e. not
> require Schema support).
>
> So far I haven't seen anything...
>
> --
> Adam Retter
>
> skype: adam.retter
> tweet: adamretter
> http://www.adamretter.org.uk
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>
>
--
Adam Retter
skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk
More information about the talk
mailing list