I have following xml file. I need to find members are in $c which are not in $v:
(C) - (V) = desired result
let $c := /transport/trips/trip
let $v := /transport/trips/trip
where (data($c/@vehicle)="PKR856")
return
<result2>
{$v/(from|to|through)/string()}
{$c/(from|to|through)/string()}
</result2>
Now I wan to subtract them and here is my code:
let $c := /transport/trips/trip
let $v := /transport/trips/trip
where (data($c/@vehicle)="PKR856")
return
<result2>
{ $c/(from|to|through)/string()[not(. = $v/(from|to|through)/string())]}
</result2>
I have tried this also is not workoing:
let $c := /transport/trips/trip/
let $v := /transport/trips/trip/(from|to|through)/string()
where (data($c/@vehicle)="PKR856")
return
<result2>
{ $c/(from|to|through)/string()[not(. = $v)]}
</result2>
output:
internal error code, argument
EDIT
Here is the XML file:
<trips>
<trip driver="d2345" vehicle="PKR856" date="12-DEC-2007">
<from>London</from>
<to>Newcastle</to>
<through stop="1">Leicester</through>
<through stop="2">Nottingham</through>
<time>1</time>
</trip>
<trip driver="d6767" vehicle="UUQ007" date="10-MAY-2008">
<from>Paris</from>
<to>Rome</to>
<through stop="1">Lyon</through>
<through stop="2">Milan</through>
<time>15</time>
</trip>
<trip driver="d2345" vehicle="PKR856" date="14-DEC-2007">
<from>Paris</from>
<to>Amsterdam</to>
<through stop="2">Brussel</through>
<through stop="1">Mons</through>
<time>4</time>
</trip>
</trips>
I need to return name of cities has not been visited by specific vehicle number?
I have tried these but is not working:
let $driver-cities := /trips/trip[@vehicle="PKR856"]/(from, to, through)/string()
return /trips/trip/(from, to)/string()[not(. = $driver-cities)]
I actually change the answer to:
let $c := /transport/trips/trip/(from|to|through)/text()
let $v := /transport/trips/trip[@vehicle eq "PKR856"]/(from|to|through)/text()
return
<result>
{ $c except $v}
</result>