<?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>6117</bug_id>
          
          <creation_ts>2008-09-25 09:54:09 +0000</creation_ts>
          <short_desc>[XQuery11UC] Windowing use case Q7 - error in logic</short_desc>
          <delta_ts>2009-02-17 16:04:27 +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>XQuery 3.0 Use Cases</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</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="Tim Kraska">tim</assigned_to>
          <cc>jim.melton</cc>
    
    <cc>tim</cc>
    
    <cc>xfranc</cc>
          
          <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>22042</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2008-09-25 09:54:09 +0000</bug_when>
    <thetext>The solution to windowing use case Q7 (3.15.7) does not seem to handle the case where Anton enters the building, leaves, enters again, and then Barbara enters. A new window should open each time Anton enters even if the conditions for closing the previous window have not been satisfied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22482</commentid>
    <comment_count>1</comment_count>
    <who name="Xavier Franc">xfranc</who>
    <bug_when>2008-11-19 23:33:40 +0000</bug_when>
    <thetext>Indeed, Michael.

Here is a proposal for a solution:

&lt;result&gt;{
  for sliding window $w in $seq/stream/event 
    start $s when $s/person = &quot;Anton&quot; and $s/direction = &quot;in&quot;
    only end $e when $e/person = &quot;Barbara&quot; and $e/direction = &quot;in&quot;
  where xs:dateTime($e/@time) - xs:dateTime($s/@time) &lt; xs:dayTimeDuration(&quot;PT1H&quot;)
  return 
    &lt;warning time=&quot;{ $e/@time }&quot;&gt;Barbara: Anton arrived 1h ago&lt;/warning&gt;
}&lt;/result&gt;

Notice the &quot;sliding&quot; instead of tumbling.
Probably the &quot;where&quot; could also be replaced by a &quot;and&quot; with the &quot;only end&quot; condition.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23411</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Kraska">tim</who>
    <bug_when>2009-02-03 12:14:55 +0000</bug_when>
    <thetext>The solution from Franc might cause several notifications. I would propose: 

declare variable $seq := fn:doc(&quot;person_events.xml&quot;);

&lt;result&gt;{
  for tumbling window $w in $seq/stream/event 
    start  $s when $s/person eq &quot;Anton&quot; and $s/direction eq &quot;in&quot;
    only end $e next $n when  xs:dateTime($n/@time) - xs:dateTime($s/@time) gt 
      xs:dayTimeDuration(&quot;PT1H&quot;) 
      or  ($e/person eq &quot;Barbara&quot; and $e/direction eq &quot;in&quot;) 
      or ($e/person eq &quot;Anton&quot; and $e/direction eq &quot;out&quot;)
  where $e/person eq &quot;Barbara&quot; and $e/direction eq &quot;in&quot;
  return 
    &lt;warning time=&quot;{ $e/@time }&quot;&gt;Barbara: Anton arrived 1h ago&lt;/warning&gt;
}&lt;/result&gt;


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23793</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Kraska">tim</who>
    <bug_when>2009-02-17 15:32:37 +0000</bug_when>
    <thetext>For the current working draft I used my solution and I mark this bug FIXED.  Mike, if you agree with my solution, please mark it CLOSED. 
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>