Need help with a homework assignment. I have two XML files: Person.xml and passedExams.xml
Person.xml form ->
<listWrapper>
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="person">
<address>Random street 2, Neverland</address>
<telephoneNumber>555-1-612-9999</telephoneNumber>
<name>Captain</name>
<sid>35168589</sid>
<surname>Obvious</surname>
</items>
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="person">
<address>Random avenue, Neverland</address>
<telephoneNumber>555-1-123-9999</telephoneNumber>
<name>Gabe</name>
<sid>36431731</sid>
<surname>Newell</surname>
</items>
</listWrapper>
passedExams.xml form ->
<listWrapper>
<items xsi:type="passedExams" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id>
<ExamID>BM3409</ExamID>
<sid>36431731</sid>
</id>
<month>7</month>
<grade>4</grade>
</items>
<items xsi:type="passedExams" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id>
<ExamID>MV7402</ExamID>
<sid>36441189</sid>
</id>
<month>7</month>
<grade>4</grade>
</items>
</listWrapper>
Using those two files I'm trying to list all people who have passed x exams in y month of the year. For example, fetch all people who have passed 2 exams in 10th month of the year. I'm having trouble in writing a good query cause I'm not good with it. This is what I got so far:
for $exam in doc("pasedExams.xml")/listWrapper//items[month = 1]
where $person in doc("Person.xml")/listWrapper/items[$exam/sid = $person/sid] satisfies (count($exam/sid) = 2)
return
<info>
$person
</info>
Here x = 1 and y = 2 just for the demo. The user can choose the parameters when the program starts. To clarify logic behind this, I'm trying to iterate through exams which have happened in January and then I'm trying to match SID (student ID) from the exam with one from Person.xml and then I'm counting the number of SID's occurrences in passedExams because the number of SID's occurrences is the number of passedExams by that student. When I run this in Stylus Studio is shows this error: [DataDirect][XQuery][err:XPST0003]Error at line 2, column 14. Expected "return", but encountered "in".
How can I make this work?