0

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 Answers2

0

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.

joemfb
  • 3,056
  • 20
  • 19
  • I've tried ne, but that can only be used with one value it seems. Since $id and $s2 both hold more than one value in my case, is there any way I can make ne work? – user1547052 Apr 09 '14 at 18:28
0

$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)])
Paul
  • 608
  • 1
  • 9
  • 23