I have been working on my 2nd simple query for a few days. All I am supposed to do is declare a global variable ($crimes) that points to all crime elements in the XML file and use a FLWOR query to iterate through each unique value of the day element so that I can see which days have the most crimes (it should be Saturday, Monday, and then Sunday in order). I also keep getting this error:
Unexpected end of query; variable "$crimes".
Code:
xquery version "1.0"; delare variable $crimes := doc('dc_crime.xml')//crime; (: Query to display total number of crimes by day of the week :) <results>{ for $day in distinct-values(doc('dc_crime.xml')/$day let $crimes := sum($crimes/($day/$crimes)) order by $day descending order return <crime day="{$day}" crimes="{$count}">{$crimes}</crime> }</results>
Sample of XML:
<crime id="13402531"> <dateTime>2013-08-31T20:27:00</dateTime> <month>8-Aug</month> <day>7-Sat</day> <offense>THEFT/OTHER</offense> <method>OTHERS</method> <ward>3</ward> </crime> <crime id="13402533"> <dateTime>2013-08-28T17:06:00</dateTime> <month>8-Aug</month> <day>4-Wed</day> <offense>THEFT F/AUTO</offense> <method>OTHERS</method> <ward>1</ward> </crime> <crime id="13402547"> <dateTime>2013-08-31T20:05:00</dateTime> <month>8-Aug</month> <day>7-Sat</day> <offense>THEFT F/AUTO</offense> <method>OTHERS</method> <ward>6</ward> </crime> <crime id="13402704"> <dateTime>2013-08-03T17:29:00</dateTime> <month>8-Aug</month> <day>7-Sat</day> <offense>THEFT/OTHER</offense> <method>OTHERS</method> <ward>2</ward> </crime> </crimes>
Please help...
No comments:
Post a Comment