XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Geoffrey NuttingSubject: 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?

Thanks,

Jeff Nutting

Postnext
Minollo I.Subject: make sequence
Author: Minollo I.
Date: 16 Aug 2007 09:25 PM
Not sure that's what you are trying to do, but this example will return a sequence of items excluding the one(s) with film-id = 2:

let $doc := <filmlist><film-id>1</film-id><film-id>2</film-id><film-id>3</film-id></filmlist>
let $excludedItems := $doc/film-id[.=2]
return
$doc/film-id except $excludedItems

Postnext
Geoffrey NuttingSubject: 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

Thanks for your insights,

Jeff Nutting

Posttop
Minollo I.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.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.