W3C home > Mailing lists > Public > www-xml-linking-comments@w3.org > April to June 2002

XPointer: definition of equal points

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sat, 13 Apr 2002 12:12:38 -0400 (EDT)
Message-ID: <41981529825.20020413171228@jenitennison.com>
To: www-xml-linking-comments@w3.org
Hi,

I'm confused about the definition for two points being equal. Say you
have:

  <foo>text<bar /></foo>

Consider these two points:

  A. the point between the 't' and the 'e' of the text node, with a
     container node of the text node within foo, and an index of 1. As
     an XPath: foo/text()/point()[1].

  B. the point between the text node child of foo and the bar
     element child of foo, with a container node of the foo element, and
     an index of 1. As an XPath: foo/point()[1].

When comparing two points to see which one is first, you use the
concept of the "immediately preceding node". For character points
(such as point A), the immediately preceding node is the container
node, so in this case the text node (foo/text()). For node points with
a non-zero index (such as point B), the immediately preceding node is
the nth child of their container node (where n is equal to their
index), in this case the first child of foo, the text node
(foo/text()).

So A and B both have an immediately preceding node that is the
foo/text() node, and an index of 1. According to the definition of
document order between two points:

  "Two points P1 and P2 are equal if their immediately preceding nodes
   are equal and the indexes of the points are equal."

so according to this, the points A and B are equal -- they have the
same immediately preceding node, and the same index.

What's more, if there's point C:

  C. the point between the 'x' and 't' of the text node, with a
     container node of the text node within foo, and an index of 2. As
     an XPath: foo/text()/point()[2].

Point C's immediately preceding node is the text node again, but this
has an index of 2. The same definition of document order between two
points says:

  "P1 is before P2 if P1's immediately preceding node is before P2's,
   or if their immediately preceding nodes are equal and P1's index is
   less than P2's."

So according to this, point B is *before* point C -- they have the
same immediately preceding node and point B's index (1) is less than
point C's index (2). This is despite the fact that point B is the
point after the text node that contains point C.

Perhaps I'm missing something, but this doesn't seem to make sense. I
think the problem is the definition of the immediately preceding node
for character points. I think it works better if you define it as
being the same as the immediately preceding node of the node point
before the character point's container node.

Cheers,

Jeni
---
Jeni Tennison
http://www.jenitennison.com/
Received on Monday, 15 April 2002 06:58:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 October 2009 08:39:43 GMT