Inserts into root nodes within if statements
Hi there,
i'm confused about following behavior. Consider the query:
"insert node <c/> into /" it evaluates perfectly if a DB is opened within the BaseX Gui (7.7). But if i put it into an if statement like: "if(true())then insert node <c/> into / else()" i got the error message that the if statement is not complete. Adding a dot behind the slash solves the problem. "if(true())then insert node <c/> into /. else()"
Is there a specific reason behind that?
Regards and thanks in advanced, Marcel
Hi Marcel,
the XPath grammar allows spaces after slashes, which is why your query is interpreted as..
... into /else ...
You can avoid this by using additional parentheses:
if(true()) then (insert node <c/> into /) else ()Hope this helps, Christian ___________________________
2013/8/15 Marcel Hanser <marcel.hanser at uni-konstanz.de>:
Quoted text · Marcel Hanser · 21 lines
> Hi there, > > i'm confused about following behavior. > Consider the query: > > "insert node <c/> into /" > it evaluates perfectly if a DB is opened within the BaseX Gui (7.7). But if > i put it into an if statement like: > "if(true())then insert node <c/> into / else()" > i got the error message that the if statement is not complete. > Adding a dot behind the slash solves the problem. > "if(true())then insert node <c/> into /. else()" > > Is there a specific reason behind that? > > Regards and thanks in advanced, > Marcel > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Christian,
thank you very much; makes perfectly sense.
Regards, Marcel
Quoted text · Christian Grün · 38 lines
Am 15.08.2013 17:48, schrieb Christian Grün: > Hi Marcel, > > the XPath grammar allows spaces after slashes, which is why your query > is interpreted as.. > > ... into /else ... > > You can avoid this by using additional parentheses: > > if(true()) then (insert node <c/> into /) else () > > Hope this helps, > Christian > ___________________________ > > 2013/8/15 Marcel Hanser <marcel.hanser at uni-konstanz.de>: >> Hi there, >> >> i'm confused about following behavior. >> Consider the query: >> >> "insert node <c/> into /" >> it evaluates perfectly if a DB is opened within the BaseX Gui (7.7). But if >> i put it into an if statement like: >> "if(true())then insert node <c/> into / else()" >> i got the error message that the if statement is not complete. >> Adding a dot behind the slash solves the problem. >> "if(true())then insert node <c/> into /. else()" >> >> Is there a specific reason behind that? >> >> Regards and thanks in advanced, >> Marcel >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
I find it kind of a loose enough syntax. I think I'll consistently parenthesize these things. I'd argue it should have been obligatory.
Quoted text · Marcel Hanser · 58 lines
On Thu, Aug 15, 2013 at 6:10 PM, Marcel Hanser < marcel.hanser at uni-konstanz.de> wrote: > Hi Christian, > > thank you very much; makes perfectly sense. > > Regards, > Marcel > > > Am 15.08.2013 17:48, schrieb Christian Grün: > > Hi Marcel, >> >> the XPath grammar allows spaces after slashes, which is why your query >> is interpreted as.. >> >> ... into /else ... >> >> You can avoid this by using additional parentheses: >> >> if(true()) then (insert node <c/> into /) else () >> >> Hope this helps, >> Christian >> ___________________________ >> >> 2013/8/15 Marcel Hanser <marcel.hanser at uni-konstanz.de**>: >> >>> Hi there, >>> >>> i'm confused about following behavior. >>> Consider the query: >>> >>> "insert node <c/> into /" >>> it evaluates perfectly if a DB is opened within the BaseX Gui (7.7). But >>> if >>> i put it into an if statement like: >>> "if(true())then insert node <c/> into / else()" >>> i got the error message that the if statement is not complete. >>> Adding a dot behind the slash solves the problem. >>> "if(true())then insert node <c/> into /. else()" >>> >>> Is there a specific reason behind that? >>> >>> Regards and thanks in advanced, >>> Marcel >>> ______________________________**_________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-**konstanz.de<BaseX-Talk at mailman.uni-konstanz.de> >>> https://mailman.uni-konstanz.**de/mailman/listinfo/basex-talk<https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk> >>> >> > ______________________________**_________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-**konstanz.de <BaseX-Talk at mailman.uni-konstanz.de> > https://mailman.uni-konstanz.**de/mailman/listinfo/basex-talk<https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk> >
Written for BaseX 7.7. BaseX may have changed since: please check the current documentation.