0
votes

I am trying to list the IDs of students who have all A's. Here is my XQuery:

for $s1 in doc("Unv.xml")//Enrollment[Grade = 'A']/StudentInfo/@oID
let $s2 := doc("Unv.xml")//Enrollment[Grade != 'A']/StudentInfo/@oID
where every $id in $s1
satisfies ($id != $s2)
return <StraightA> { $s1 } </StraightA>;

and here is a snippet of the Enrollment Section I am pulling the data from:

<Enrollment EnrollmentID="Enrollment217">
    <OfferingInfo oType="OfferingType" oID="Offering009"/>
    <StudentInfo oType="StudentType" oID="s895255243"/>
    <Grade>B</Grade>
</Enrollment>

However, this only gives me a list of students who have at least one A. Thoughts?

2

2 Answers

0
votes

In XQuery = and != are sequence comparison operators; they are satisfied by one match in a sequence of values. eq and ne are the value comparison operators, and they work the way you would expect.

0
votes

$s1 is list of ids of students who have at least one A. $s2 is list of ids of students who have at least one non-A.

functx:value-except((1,2,3),(3,4,5))
(1, 2)

  distinct-values($arg1[not(.=$arg2)])