|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] problem with loopsTitash Neogi titash_neogi at symantec.comWed Jan 4 03:46:45 PST 2006
Thanks a Lot!! This worked like a breeze. :) Thanks again. Titash -----Original Message----- From: John Snelson [mailto:http://xquery.com/mailman/listinfo/talk] Sent: Wednesday, January 04, 2006 4:59 PM To: Titash Neogi Cc: http://xquery.com/mailman/listinfo/talk Subject: Re: problem with loops In that case, you'll want to do something like this: declare function local:depends($map as node(), $name as xs:string) as xs:string* { let $entry := $map/maps/map[res = $name] let $depend := string($entry/pre) return if(exists($entry)) then ($name, local:depends($map, $depend)) else $name }; local:depends(doc("file.xml"), "DATA4") Which should do want you want. John Titash Neogi wrote: > Thanks for the replies. > > Here is a simplified outline of what I am trying to do > > > I have a xml file as shown below > > <maps> > <map> > <pre> DATA0 </pre> <res> DATA1 </res> </map> > <map> > <pre> DATA1 </pre> <res> DATA2 </res> </map> > <map> > <pre> DATA2 </pre> <res> DATA3 </res> </map> > <map> > <pre> DATA3 </pre> <res> DATA4 </res> </map> > . > . > . > > </maps> > > Now the idea is that if I search for DATA4, the system will trace its > path backwards and find out all the linked dependencies. So the output > would something like > > Query - DATA4 > > Result - DATA4 DATA3 DATA2 DATA1 DATA0 > > > The algorithm I am trying to implement is > > 1. Obtain input from user > > 2. repeat steps 3 through 5 for the entire file > > 3. send user input to function A that identifies the <map> </map> chunk > corresponding to this input > > 4. send the output of function A (step 3) to a function B that extracts > the pre/text() bit of this chunk > > 5. send the output of function B (step 4) to function A (step 3 again) > to identify the <map> </map> chunk > > > Now, to repeat, my problem is that my function overwrites the values in > the loop so that I only get the last variable's output. > > Hope this makes the logic a little clearer. > > Any further help on this would be really nice. > > Thanks > Titash -- John Snelson, Berkeley DB XML Engineer Sleepycat Software, Inc http://www.sleepycat.com Contracted to Sleepycat through Parthenon Computing Ltd http://blog.parthcomp.com/dbxml
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






