RE: Older Sibling?

> Given that XML is ordered, it does seem pretty strange to not be able to
> determine what order any given two things are in.

Being ordered, and being able to easily extract ordering information, are
two different things.

All the information required does already exist in the DOM API, though not
in a convenient form:

     Make sure the two nodes aren't the same node
          (if they are, neither preceeds the other)
     Find lowest common ancestor of the two nodes
     Walk its immediate children left to right
     Stop when you find the first child whose subtree contains one of the
          two nodes. That node comes before the other.

Implementation is left as an exercise for the reader.


We don't currently define a single-step query which _only_ returns the
who-comes-first information. (Nor does the Infoset, as far as I know.)

As has been noted there may be reason to add this, both for convenience and
because some DOMs may be able to offer a faster implementation based on
internal knowledge. But it doesn't necessarily have to be added in Level 2,
since the do-it-yourself calculation does work.

Certainly worth further consideration. It's been placed on the open issues
list.


______________________________________
Joe Kesselman  / IBM Research

Received on Tuesday, 29 February 2000 13:55:15 UTC