[Xpath-ng] My favorite XPath language]

Joe English jenglish at flightlab.com
Thu Nov 21 16:25:31 MST 2002


Berend de Boer wrote:

> Perhaps it is also helpful if people try to post:
>
> 1. What is *wrong* with Xpath.

Number one on my list is the overloaded semantics for "[expr]".

(That is: if "expr" evaluates to a boolean, "[expr]" is a filter.
If "expr" evaluates to any other type _except for a number_
then "[expr]" is the same as "[boolean(expr)]".  If OTOH
expr evaluates to a number, the semantics are completely
different.)

Number two on my list is the node set vs. node list distinction.
The problem being that XPath doesn't _make_ the distinction;
instead it augments nodes in a node set with "context positions"
when it needs to do list-like operations.  XPath processors
have to go through a lot of trouble to get the semantics
right, converting from lists to sets and back again in just
the right places.  The whole thing could be vastly simplified
if XPath dealt exclusively with ordered lists of nodes, possibly
with a function to sort a list into document order and remove
duplicates for those cases where "set" semantics really are needed.

Number three is mandating IEEE floating point for numbers,
complete with the rules for NaNs and infinities.  This is
fine for Java implementations where all the world is a
32-bit CPU with IEEE 754 support, but it's a bit of a
headache for most other languages (like C89, where 1.0/0.0
is "undefined behavior" instead of +Infinity).

Of course if we're talking about XPath 2.0, then the
WXS data type infection takes the #1 spot on my
list of what's wrong :-)


> 2. What should be added to Xpath, and *why* can't we do without.
> 3. Can't we create a better Xpath by taking things away?

I think we could do without big chunks of the expression
language, or at least factor those out into an optional module.
Many XML APIs use XPath as an embedded sublanguage (like
regexps, SQL, etc.), and since the host language usually
has its own collection of arithmetic and string processing
facilities there's little need to duplicate them in XPath.



--Joe English

  jenglish at flightlab.com



More information about the Xpath-ng mailing list