Inserts into root nodes within if statements

Thursday, 15 August 2013 · 4 messages
MH
Marcel Hanser15 Aug 2013 16:39 #
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
CG
Christian Grün15 Aug 2013 17:48 #
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
MH
Marcel Hanser15 Aug 2013 18:10 #
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
GJ
Gerald de Jong15 Aug 2013 19:14 #
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> >
-- Delving BV, Vasteland 8, Rotterdam http://www.delving.eu http://twitter.com/fluxe skype: beautifulcode +31629339805

⚡Generated with XQuery