- From: Michael Brundage <xquery@comcast.net>
- Date: Tue, 17 Feb 2004 11:01:11 -0800
- To: Mary Holstege <mary@cerisent.com>, XQuery Public Comments <public-qt-comments@w3.org>
Those functions type-check their arguments but don't change the static type
of the expression.
I think you want:
define function exactly-one ( $items as item()* ) as item() {
$items treat as item()
}
define function one-or-more ( $items as item()* ) as item()? {
$items treat as item()?
}
define function zero-or-more ( $items as item()* ) as item()* {
$items treat as item()*
}
which should take any sequence of items, change their cardinality
statically, and error dynamically if the cardinality change is not valid.
Cheers,
Michael Brundage
xquery@comcast.net
Writing as
Author, XQuery: The XML Query Language (Addison-Wesley, 2004)
Co-author, Professional XML Databases (Wrox Press, 2000)
not as
Technical Lead
Common Query Runtime/XML Query Processing
WebData XML Team
Microsoft
On 2/17/04 10:16 AM, "Mary Holstege" <mary@cerisent.com> wrote:
>> How can a user write a function that statically reduces the type and
>> raises an error if the dynamic cardinality is too big?
>> Best regards
>> Michael
>
> Perhaps I'm missing something, but I don't see why these don't do the
> trick.
> The rules for sequence type matching allow you to report this either
> statically
> or dynamically:
>
>
> define function exactly-one ( $items as item() ) as item()*
> {
> $items
> }
>
> define function one-or-more ( $items as item()+ ) as item()*
> {
> $items
> }
>
> define function zero-or-more ( $items as item()* ) as item()*
> {
> $items
> }
>
> //Mary
>
Received on Tuesday, 17 February 2004 14:01:12 UTC