Re: Older Sibling?

>> Given two nodes of a common parent, identify which node precedes the
>> in the parent's ChildNodes nodelist.
>> Is there such a creature in the current specs?
>You'd basically look at the nodelist yourself.  Takes a few lines
>of code -- would you seriously expect DOM to save you the work of
>writing such a simple subroutine?  If so, why?

I've heard one strong case where an ordering query would be useful -- not
on NodeLists, but on lists of nodes generated in other ways.  That case is
XSLT. It's not uncommon there to want to take the union of several
seperately executed searches and present it as a single list of nodes, in
document order. In that situation, convolving the lists to interleave them
correctly can be a significantly expensive operation.

We've had periodic requests from XSLT developers to add a
Node.isBefore(Node) operation, which they could invoke in the hope that a
specific DOM might have an underlying representation which permits
optimizing this operation. Given that some models _can_ answer this
question much more quickly via their internal representations than via
their DOM API, I think it's worth considering.

Statement of bias: I wrote one such model; that fast-ordering feature is
one of several reasons LotusXSL/Xalan prefers to read the input document
from DTM rather than from a "normal" DOM.

Joe Kesselman  / IBM Research

Received on Monday, 28 February 2000 18:30:46 UTC