This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6538 - [FS] Inconsistent following-sibling behaviour of attribute nodes
Summary: [FS] Inconsistent following-sibling behaviour of attribute nodes
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Formal Semantics 1.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Michael Dyck
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-06 14:07 UTC by Nick Jones
Modified: 2009-02-17 01:52 UTC (History)
0 users

See Also:


Attachments

Description Nick Jones 2009-02-06 14:07:10 UTC
I believe the behaviour of following-sibling is in the language and formal semantics specifications, particularly with respect to starting on an attribute node.

3.2.1.1 of the language spec states: "if the context node is an attribute node, the following-sibling axis is empty"

4.2.1.1 of the formal semantics states:

[following-sibling:: NodeTest]Axis
==
[let $e := . return $e/parent::node()/child:: NodeTest [.>>$e]]Expr


This normalization doesn't reflect the same behaviour when starting on an attribute node.

Further, if this normalization were changed to match the language spec it cause the normalization of the following:: axis to be different when starting on an attribute node, as this is normalized as:

[following:: NodeTest]Axis
==
[ancestor-or-self::node()/following-sibling::node()/descendant-or-self:: NodeTest]Expr

But the language spec does not define an empty sequence when starting on an attribute node for the following:: axis.
Comment 1 Michael Dyck 2009-02-08 07:03:53 UTC
I agree, FS's normalization rule for following-sibling is incorrect.
I propose we fix it by adding a 'where' clause to the right-hand side:

    [
        let $e := .
        where fn:not($e/self::attribute())
        return $e/parent::node()/child:: NodeTest [.>>$e]
    ]_Expr

And thanks for the heads-up re the following:: axis, although I believe
the danger is not that it would mistakenly yield an empty sequence,
but rather that it would yield a sequence that is missing the descendants 
of the attribute's parent. We could add them in explicitly, but I think
that would be fairly ugly. Instead, I suggest we go back to the definition:

    the 'following' axis contains all nodes that are descendants
    of the root of the tree in which the context node is found,
    are not descendants of the context node, and occur after
    the context node in document order

and express it thusly:

    [ following:: NodeTest ]_Axis
    ==
    [
        let $e := .
        return
            fn:root() / descendant:: NodeTest [. >> $e]
            except
            $e / descendant::node()
    ]_Expr
Comment 2 Michael Dyck 2009-02-08 07:05:48 UTC
The XQuery test suite doesn't appear to have any tests for applying the
following-sibling axis to an attribute node. I suggest something like:

    <foo a='1' b='2' c='3'>
        <bar>4</bar>
        <bar>5</bar>
        <bar>6</bar>
    </foo>/@a/following-sibling::node()

yielding empty.

Similarly for preceding-sibling (but using @c, on the off-chance some implementation thinks attributes a and b are preceding-siblings of
attribute c).
Comment 3 Nick Jones 2009-02-09 12:32:41 UTC
Those two normalizations looks reasonable to me. I've tried them out in our implementation and they both seem to fix the tests which originally showed the problem (axes102 and axes108 in the XSLT test suite) without breaking any previously working tests in that or XQTS.


Comment 4 Michael Dyck 2009-02-11 06:55:02 UTC
At their meeting this morning, the joint WGs approved the solution proposed
in Comment #1. Consequently, I'm marking this issue resolved-FIXED. If you
agree with this resolution, please mark the issue CLOSED.
Comment 5 Michael Dyck 2009-02-17 01:52:17 UTC
This issue has been entered as FS erratum E060, and the proposed fixes have
been committed to the source files for the next edition of the FS document.