<?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>2708</bug_id>
          
          <creation_ts>2006-01-11 21:55:03 +0000</creation_ts>
          <short_desc>Errors and Optimization and Cardinality checks</short_desc>
          <delta_ts>2006-02-15 21:59:36 +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>XPath 2.0</component>
          <version>Candidate 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="Michael Kay">mike</reporter>
          <assigned_to name="Don Chamberlin">chamberl</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>7803</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-01-11 21:55:03 +0000</bug_when>
    <thetext>Section 2.3.4 says:

&quot;Another consequence of these rules is that where none of the items in a
sequence contributes to the result of an expression, the processor is not
obliged to evaluate any part of the sequence. Again, however, the processor
cannot dispense with a required cardinality check: if an empty sequence is not
permitted in the relevant context, then the processor must ensure that the
operand is not an empty sequence.&quot;

It&apos;s not clear quite how much checking this requires.

Consider

(1,2,3) = (1,2,exactly-one(//title))

//title is not allowed to return an empty sequence. Does this mean we are
required to evaluate it and check it? I think we would agree that it does not.
In other words, the requirement to do cardinality checking does not cascade.

Now consider

max((), resolve-uri($collation, &apos;http://base/&apos;))

Does the quoted paragraph mean that I am required to determine that the
collation is not (), even though the result of the max() function is clearly (),
regardless of the actual collation? It seems to me that the wording of the above
paragraph says that this is indeed required. If that&apos;s the case, it seems wrong:
it&apos;s a quite unnecessary constraint on the way the processor operates. Whether
the decision is made statically or dynamically, we should always have the
freedom to avoid evaluating an expression if its value is not needed.

Perhaps we could use a form of words such as: if an expression is evaluated
(wholly or in part), then it must be evaluated sufficiently to ensure that any
cardinality constraints on the value of the expression are satisfied.

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8275</commentid>
    <comment_count>1</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2006-02-15 21:59:26 +0000</bug_when>
    <thetext>Mike,
The Query and XSLT working groups considered your comment during their joint 
meeting on 01 Feb 2006, and agreed to make editorial changes to Section 2.3.4 
(Errors and Optimization) of the XPath and XQuery specifications, clarifying 
that cardinality checking is required only for expressions that are evaluated, 
wholly or in part. Since you were present at the discussion, I have marked this 
issue as Closed.
Regards,
Don Chamberlin (for the joint working groups)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>