<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>6538</bug_id>
          
          <creation_ts>2009-02-06 14:07:10 +0000</creation_ts>
          <short_desc>[FS] Inconsistent following-sibling behaviour of attribute nodes</short_desc>
          <delta_ts>2009-02-17 01:52:17 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Formal Semantics 1.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nick Jones">nick</reporter>
          <assigned_to name="Michael Dyck">jmdyck</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>23498</commentid>
    <comment_count>0</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2009-02-06 14:07:10 +0000</bug_when>
    <thetext>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: &quot;if the context node is an attribute node, the following-sibling axis is empty&quot;

4.2.1.1 of the formal semantics states:

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


This normalization doesn&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23567</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-08 07:03:53 +0000</bug_when>
    <thetext>I agree, FS&apos;s normalization rule for following-sibling is incorrect.
I propose we fix it by adding a &apos;where&apos; clause to the right-hand side:

    [
        let $e := .
        where fn:not($e/self::attribute())
        return $e/parent::node()/child:: NodeTest [.&gt;&gt;$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&apos;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 &apos;following&apos; 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 [. &gt;&gt; $e]
            except
            $e / descendant::node()
    ]_Expr</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23568</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-08 07:05:48 +0000</bug_when>
    <thetext>The XQuery test suite doesn&apos;t appear to have any tests for applying the
following-sibling axis to an attribute node. I suggest something like:

    &lt;foo a=&apos;1&apos; b=&apos;2&apos; c=&apos;3&apos;&gt;
        &lt;bar&gt;4&lt;/bar&gt;
        &lt;bar&gt;5&lt;/bar&gt;
        &lt;bar&gt;6&lt;/bar&gt;
    &lt;/foo&gt;/@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).
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23593</commentid>
    <comment_count>3</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2009-02-09 12:32:41 +0000</bug_when>
    <thetext>Those two normalizations looks reasonable to me. I&apos;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.


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23634</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-11 06:55:02 +0000</bug_when>
    <thetext>At their meeting this morning, the joint WGs approved the solution proposed
in Comment #1. Consequently, I&apos;m marking this issue resolved-FIXED. If you
agree with this resolution, please mark the issue CLOSED.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23781</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-02-17 01:52:17 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>