Subject:make sequence Author:Geoffrey Nutting Date:16 Aug 2007 08:06 PM
Hi,
I have a couple hundred entries in a field
/filmlist/film-id
that I want to be able to handle as a sequence of film-id entries(I actually have 3 files of these that I want to compare) but I can't figure out how to turn this file into a sequence, so I could hopefully handle the results with something like the except'operator.
These were my current thoughts on how to approach the problem, but maybe that's not the best way? Comments on better ways to approach the problem?
Subject:make sequence Author:Geoffrey Nutting Date:17 Aug 2007 12:25 AM
better explanation:assume I have a file that looks like
<filmlist><film-id>1</film-id><film-id>2</film-id><film-id>3</film-id><film-id>4</film-id></filmlist>
actually, I was assuming I had 3 files, & wanted to generate a sequence of film-ids for each of them: for the one above, I should have
$fida = (1,2,3,4)
etc, similarly for $fidb, $fidc, so I can find the difference in the files film-ids using something like
$dif = $fida except $fidb
since the files are rather long, I was wondering if there was a way to automatically construct the sequences $fida, etc
Subject:make sequence Author:Minollo I. Date:17 Aug 2007 09:22 AM
You can't use op:except then; it works on nodes, and it relies on node identity, which isn't what you need if you are dealing with "similar" nodes coming from different files.
You can probably do something like this:
let $fida := doc('file:///c:/filmlist1.xml')//film-id/number(),
$fidb := doc('file:///c:/filmlist2.xml')//film-id/number(),
$fidc := doc('file:///c:/filmlist3.xml')//film-id/number()
return
$fida[not(index-of($fidb,.)) and not(index-of($fidc,.))]
...it will return all IDs in the first list of films that are not also contained in the other lists.