[Xpath-ng] Positional predicates (WAS: Minimal FIXPath (with a bonus)?)

Jeni Tennison jeni at jenitennison.com
Thu Jan 9 06:48:47 MST 2003


Hi David,

> So I think we could consider a rule that made [...] positional only
> if ... is known statically at compile time to be a number.

Hrm. I think that this might be a dangerous rule, since it would mean
that either:

  (a) we'd have to specify in mind-numbing detail exactly what is and
      isn't known statically or

  (b) we'd end up with different implementations doing different
      things depending on how good their static type checking was

I'm in favour of leaving it up to implementations to decide which
static typing rules they want to apply rather than fixing this in the
spec. This gives implementations something to compete over and saves
us a lot of work. But it does mean that if we start talking about
what's known statically and what isn't then we may end up with
different implementations doing different things, for example one
implementation recognising:

  count(foo) + 3

statically as being a number while another doesn't. Which means, I
think, that we shouldn't base the interpretation of an expression on
what's known statically and what's not.

Another alternative would be close to what you suggest:

> The simplest version of the rule would be that positional predicates had
> to be of the form
> [ optional-white-space numeric-literal  optional-white-space]
> That would already catch a large percentage of current usage.

by saying that the predicate is only interpreted as being positional
if it either contains a numeric literal or a call to the function
last(). As you say, that would catch a large percentage of current
usage. I think it's probably better practice to use position() = ...
in other cases anyway (although of course I always go for the shorter
option) -- it's not only processors that struggle to work out whether
an expression returns a number or not, humans do as well!

What do you think?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/




More information about the Xpath-ng mailing list