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 26859 - orderBy63 may not test intended error conditions
Summary: orderBy63 may not test intended error conditions
Status: RESOLVED FIXED
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: O'Neil Delpratt
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-19 14:29 UTC by Josh Spiegel
Modified: 2014-11-19 00:01 UTC (History)
1 user (show)

See Also:


Attachments

Description Josh Spiegel 2014-09-19 14:29:04 UTC
<test-case name="orderBy63" xmlns="http://www.w3.org/2010/09/qt-fots-catalog">
      <description>Test that the context item for evaluating a sort key is NOT the item whose sort key is being computed</description>
      <created by="Michael Kay" on="2011-07-30"/>
      <environment ref="orderdata"/>
      <dependency type="spec" value="XQ10+"/>
      <test><![CDATA[
        declare default element namespace "http://www.w3.org/XQueryTestOrderBy"; 
        /DataValues/(
            for $x in NegativeNumbers/orderData
            order by xs:decimal(.)
            return $x)]]></test>
      <result>
         <any-of>
            <error code="FOTY0004"/>
            <error code="FOTY0012"/>
            <error code="FORG0001"/>
         </any-of>
      </result>
</test-case>

Some implementations may be able to compute the result of this query without evaluating the order by clause, thereby avoiding the error condition (which is allowed under 2.3.4 Errors and Optimization).  I would like to modify the query to force the order by clause to be relevant to the result.  For example:

        declare default element namespace "http://www.w3.org/XQueryTestOrderBy"; 
        /DataValues/(
            (
            for $x at $pos in NegativeNumbers/orderData
            order by xs:decimal(.) + $pos
            return $x
            )[1]
        )
Comment 1 Michael Kay 2014-11-14 10:00:47 UTC
I don't think the proposed change helps much. An implementation can still determine that xs:decimal(.) contributes nothing to the sorting. A better fix would be one where the test is made error-free. Perhaps 

/DataValues/(
            for $x in NegativeNumbers/*
            order by (if name(.) = 'orderData' then $x else -$x)
            return $x)

which produces different results depending on the context item used to evaluate name(.).
Comment 2 Josh Spiegel 2014-11-14 16:45:07 UTC
The results of the path expression should be in document order so the order by can still be eliminated in your version.

What about this:

  /DataValues/(
    (
      for $x in NegativeNumbers/*
      order by (if (name(.) = 'orderData') then $x else -$x)
      return $x
    )[1]
  )

With expected result:

  <orderData xmlns="http://www.w3.org/XQueryTestOrderBy">-0</orderData>
Comment 3 Michael Kay 2014-11-14 18:30:20 UTC
I missed the document order problem: could solve that by using "!" instead of "/".
Comment 4 Josh Spiegel 2014-11-14 18:55:39 UTC
I think that would work as well except currently it is a 1.0 test.
Comment 5 Josh Spiegel 2014-11-19 00:01:56 UTC
I applied the fix in Comment 2 since it appears to achieve the goal of the test without restricting it to 3.0+.  Please reopen if you see a problem with this.