XQuery comments in Return clause?
Wednesday, 9 April 2014 · 3 messages · last reply 10 Apr 2014
HE
Hondros, Constantine (ELS-AMS)9 Apr 2014 23:53 #
Hi all,
I can't tell if this is a bug or not.
I commented out a line in my Return clause so that I could test performance. To my surprise, the comment was interpreted as part of the literal response, and the expression within the commented line was evaluated. If this is expected behaviour, is there a workaround?
return
<dup>
<pii>{ $val }</pii>
(: {/results/dataset/item[pii = $val]/dbpath} :)
</dup>----------------------
Result:
----------------------
<dup>
<pii>0022-0728(92)80265-6</pii>
(: <dbpath>SCODAT00000000001/15726657/v336i1-2/0022072892802657/main.xml</dbpath>
<dbpath>SCODAT00000000002/15726657/v336i1-2/0022072892802656/main.xml</dbpath> :)
</dup>
<dup>________________________________
Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The Netherlands, Registration No. 33156677, Registered in The Netherlands.
CG
Christian Grün9 Apr 2014 23:58 #
Quoted text · Hondros, Constantine (ELS-AMS) · 4 lines
> I commented out a line in my Return clause so that I could test performance. > To my surprise, the comment was interpreted as part of the literal response, > and the expression within the commented line was evaluated. If this is > expected behaviour, is there a workaround?
This is expected behavior, as you may want to have smileys in your XML snippets:
<x> (: </x>As workaround, you can either use XML comments...
<x><!-- ... --></x>...or sth like this:
<x>{ (: ... :) () } </x>Quoted text · Hondros, Constantine (ELS-AMS) · 41 lines
> > return > > <dup> > > <pii>{ $val }</pii> > > (: {/results/dataset/item[pii = $val]/dbpath} :) > > </dup> > > > > ---------------------- > > Result: > > ---------------------- > > > > <dup> > > <pii>0022-0728(92)80265-6</pii> > > (: > <dbpath>SCODAT00000000001/15726657/v336i1-2/0022072892802657/main.xml</dbpath> > > > <dbpath>SCODAT00000000002/15726657/v336i1-2/0022072892802656/main.xml</dbpath> > :) > > </dup> > > <dup> > > > ________________________________ > > Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The > Netherlands, Registration No. 33156677, Registered in The Netherlands.
HE
Hondros, Constantine (ELS-AMS)10 Apr 2014 00:00 #
XML comments ... of course ;-)
Thanks for your incredibly fast response, Christian.
Quoted text · Christian Grün · 60 lines
-----Original Message----- From: Christian Grün [mailto:christian.gruen at gmail.com] Sent: 09 April 2014 23:58 To: Hondros, Constantine (ELS-AMS) Cc: basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] XQuery comments in Return clause? > I commented out a line in my Return clause so that I could test performance. > To my surprise, the comment was interpreted as part of the literal > response, and the expression within the commented line was evaluated. > If this is expected behaviour, is there a workaround? This is expected behavior, as you may want to have smileys in your XML snippets: <x> (: </x> As workaround, you can either use XML comments... <x><!-- ... --></x> ...or sth like this: <x>{ (: ... :) () } </x> > > return > > <dup> > > <pii>{ $val }</pii> > > (: {/results/dataset/item[pii = $val]/dbpath} :) > > </dup> > > > > ---------------------- > > Result: > > ---------------------- > > > > <dup> > > <pii>0022-0728(92)80265-6</pii> > > (: > <dbpath>SCODAT00000000001/15726657/v336i1-2/0022072892802657/main.xml< > /dbpath> > > > <dbpath>SCODAT00000000002/15726657/v336i1-2/0022072892802656/main.xml< > /dbpath> > :) > > </dup> > > <dup> > > > ________________________________ > > Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The > Netherlands, Registration No. 33156677, Registered in The Netherlands. Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The Netherlands, Registration No. 33156677, Registered in The Netherlands.
Written for BaseX 7.8. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery