Nothing gets printed after insert node
Tuesday, 5 June 2012 · 2 messages
CG
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
Quoted text · Anupam Bakshi · 85 lines
On Tue, Jun 5, 2012 at 3:49 PM, Anupam Bakshi <bakshia at 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 at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
AB
Anupam Bakshi5 Jun 2012 17:50 #
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>Written for BaseX 7.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery