Hello Christian, Unfortunately I did not see how I can return the value into a variable for further processing. Is there some other way to do it? Thanks, Anupam |
Hi Anupam, updating queries will never return results. Please consult our documentation if you are interested in the concepts of the XQuery Update Facility [1]. Christian [1] http://docs.basex.org/wiki/XQuery_Update#Concepts ___________________________ On Tue, Jun 5, 2012 at 3:49 PM, Anupam Bakshi <bakshia@yahoo.com> wrote: > Hello, > My XQuery file looks like this : > > for $metric in doc("C:\sample1.xml")//metric > return ( > delete node $metric, > insert node <NID>{string($metric)}</NID> > into $metric/.. > ) > > The sample1.xml contains "metric" elements. > > Yet when I execute the query noting gets printed out. > > Following is the Query Info which shows 6 Updates. But where are the updates > happening? > I must be doing something wrong, but can't figure it out. > > Thanks for your help, > Anupam > > Query: for $metric in doc("C:\sample1.xml")//metric return ( delete node > $metric, insert node <MET>{string($metric)}</MET> into $metric/.. ) > Compiling: > - pre-evaluating fn:doc("C:\sample1.xml") > - optimizing descendant-or-self step(s) > - converting descendant::*:metric to child steps > Result: for $metric in document-node { "sample1.xml" }/*:plan/*:metric > return (delete nodes $metric, insert node element { "MET" } { > fn:string($metric) } into $metric/..) > Timing: > - Parsing: 0.84 ms > - Compiling: 2.21 ms > - Evaluating: 3.37 ms > - Printing: 0.14 ms > - Total Time: 6.57 ms > Result: > - Hit(s): 0 Items > - Updated: 6 Items > - Printed: 0 Bytes > Query plan: > <QueryPlan> > <FLWR> > <For var="$metric"> > <IterPath> > <DBNode name="ivst3_plan_3" pre="0"/> > <IterStep axis="child" test="*:plan"/> > <IterStep axis="child" test="*:metric"/> > </IterPath> > </For> > <Return> > <List> > <Delete> > <VarRef> > <Var name="$metric" id="0"/> > </VarRef> > </Delete> > <Insert> > <AxisPath> > <VarRef> > <Var name="$metric" id="0"/> > </VarRef> > <IterStep axis="parent" test="node()"/> > </AxisPath> > <CElem> > <QNm value="MET" type="xs:QName"/> > <FNAcc name="string([item])"> > <VarRef> > <Var name="$metric" id="0"/> > </VarRef> > </FNAcc> > </CElem> > </Insert> > </List> > </Return> > </FLWR> > </QueryPlan> > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk@mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > |