Given this trades.xml:
<trades>
<trade stock="ACO" price="200" time="12:00:00.1"/>
<trade stock="ACO" price="202" time="12:00:00.2"/>
<trade stock="BCO" price="200" time="12:00:00.3"/>
<trade stock="CCO" price="300" time="12:00:00.4"/>
<trade stock="CCO" price="299" time="12:00:00.5"/>
<trade stock="CCO" price="290" time="12:00:00.6"/>
<trade stock="ACO" price="200" time="12:00:00.7"/>
<trade stock="ACO" price="205" time="12:00:03.1"/>
</trades>
Do you know why this query doesn't work? I'd like to have sliding windows of one second and to see how many trades with stock "AC0" have been sold in that windows of 1 second:
let $onesec := xs:dayTimeDuration('PT1S')
for sliding window $w
in doc("C:\Users\Lorenzo Enzino Vinci\Desktop\seminarioMontesi\trades.xml")//trade
start $s when $s/@stock eq "ACO"
end next $n when $n/@time > ($s/@time + $onesec) (: ******************** :)
let $occurrences := count ($w[@stock eq $s/@stock])where $occurrences gt 1
return <run stock="{$s/@stock}"
occurrences="{$occurrences}"
time="{$s/@time}"/>
When I try to execute, it says:
"[XPTY0004] '+' operator: number expected, xs:dayTimeDuration found."
at line with (: ******************** :)
So – how can I sum timestamps?