[Bug 4841] [FS] Use of fn:subsequence in relation to normalization rules for filter expressions in FS

http://www.w3.org/Bugs/Public/show_bug.cgi?id=4841





------- Comment #6 from mike@saxonica.com  2007-08-07 04:04 -------
I don't know what the correct notation is, but I think the required outcome can
probably be achieved by normalizing 

PrimaryExpr PredicateList [ NumericLiteral N where (N mod 1 eq 0 and N gt 0)] 

to

fn:subsequence($fs:sequence, NumericLiteral, 1)

and

PrimaryExpr PredicateList [ NumericLiteral N where (N mod 1 ne 0 or N le 0)] 

to

()

This gives the same static inference as the current rules except in cases where
the current rules get it wrong.

Unlike the previous proposals, it still infers a singleton for numeric
predicates expressed as decimals or doubles provided the actual value is equal
to an integer. It's also a very localized change.

It does mean that expressions like foo[3.4] or foo[0] will fall foul of the
static typing rule that says empty sequences are bad for your health; but that
seems well within the spirit of the Act.

If we were doing this again I think I would want to normalize both filter
expressions and subsequence to calls on a primitive such as fs:item-at(seq,
int).

Received on Tuesday, 7 August 2007 04:04:54 UTC