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 6117 - [XQuery11UC] Windowing use case Q7 - error in logic
Summary: [XQuery11UC] Windowing use case Q7 - error in logic
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.0 Use Cases (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Tim Kraska
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-25 09:54 UTC by Michael Kay
Modified: 2009-02-17 16:04 UTC (History)
3 users (show)

See Also:


Attachments

Description Michael Kay 2008-09-25 09:54:09 UTC
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.
Comment 1 Xavier Franc 2008-11-19 23:33:40 UTC
Indeed, Michael.

Here is a proposal for a solution:

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

Notice the "sliding" instead of tumbling.
Probably the "where" could also be replaced by a "and" with the "only end" condition.
Comment 2 Tim Kraska 2009-02-03 12:14:55 UTC
The solution from Franc might cause several notifications. I would propose: 

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

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


Comment 3 Tim Kraska 2009-02-17 15:32:37 UTC
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.