[Bug 6647] New: [XQuery11UC] Windowing use case Q17: Invalid query

http://www.w3.org/Bugs/Public/show_bug.cgi?id=6647

           Summary: [XQuery11UC] Windowing use case Q17: Invalid query
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Platform: PC
               URL: http://www.w3.org/TR/2008/WD-xquery-11-use-cases-
                    20081203/#windowing_Q2_most_valuable_customer
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQuery 1.1 Use Cases
        AssignedTo: jonathan.robie@redhat.com
        ReportedBy: wouter.cordewiner@datadirect.com
         QAContact: public-qt-comments@w3.org
                CC: marc.van.cappellen@datadirect.com


In XQuery 1.1 Use Cases, Working Draft 3 December 2008 the windowing use case
Q17 have query errors:

1. The window end condition is missing, ie "end when newstart" is not
appropriate for this query I think.

2. day-from-date(xs:dateTime($cur/@date)) is not correct as a xs:dateTime value
is provided where day-from-date() expects a xs:date().

Correcting both issues, I believe the corrected query should be (adhering to
the expected results):

========================================

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

<result>{
for sliding window $w in $seq/sequence/* 
  start $cur previous $prev 
   when day-from-dateTime(xs:dateTime($cur/@date)) ne
day-from-dateTime(xs:dateTime($prev/@date)) or empty($prev)
  end $end next $next
   when day-from-dateTime(xs:dateTime($end/@date)) ne
day-from-dateTime(xs:dateTime($next/@date))
return
  <mostValuableCustomer endOfDay="{xs:dateTime($cur/@date)}">{
    let $companies :=   for $x in distinct-values($w/@billTo ) 
                        return <amount company="{$x}">{sum($w[@billTo eq
$x]/@total)}</amount>
    let $max := max($companies) 
    for $company in $companies
    where $company eq xs:untypedAtomic($max)
    return $company
  }</mostValuableCustomer>
}</result>

========================================


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Tuesday, 3 March 2009 12:53:54 UTC