[basex-talk] FW: inline issue
Sent from Mail for Windows 10 From: RobStapper Sent: Thursday, June 25, 2020 1:33 PM To: basex-talk@mailman.uni-konstanz.de Subject: inline issue Hi Cristian, It has been a while. I hope all is well over there. Yep, still using BaseX and still loving it. It is a great product. However 😉 lately I encounter an issue with the %basex:inline annotation ☹ and it is bugging me. Consider both snippets [snip1], [snip2]. Both should give the same result. However they don’t and worse a can’t make the second snippet [ snip2] work conform the first snippet{snip1]. [snip1]: == if ( true() ) then "true" else error((),"false") [snip2]: == %basex:inline(0) %basex:lazy function( $pred    , $true    , $false    )    {  if ( $pred)  then $true  else $false    } ( true()  , "true"  , error((),"false")  ) Can you please have a look at this? TIA. Greatings, Rob Stapper PS. As I remember this used to work fine. I remember we had a discussion concerning inlining and laziness on 2015-06-17. Sent from Mail for Windows 10 -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus snip-1.xq Description: Binary data snip-2.xq Description: Binary data
Re: [basex-talk] FW: inline issue
Hi Rob, Glad to you hear you are fine. If you want to ensure that arguments of user-defined functions are not evaluated before the function is evaluated, you should work with function items: let $check := function( $pred as item(), $true as function() as item()*, $false as function() as item()* ) { if ($pred) then $true() else $false() } return $check(true(), true#0, function() { error((), 'false') }) In the specific case you brought up, you can instead call the built-in function util:if: util:if(true(), 'true', error((), 'false')) The third argument will only be considered if the supplied condition fails. Hope this helps, Christian > It has been a while. I hope all is well over there. > Yep, still using BaseX and still loving it. It is a great product. > > However lately I encounter an issue with the %basex:inline annotation ☹ and > it is bugging me. > > Consider both snippets [snip1], [snip2]. Both should give the same result. > However they don’t and worse a can’t make the second snippet [ snip2] work > conform the first snippet{snip1]. > > [snip1]: > == > if ( true() ) > then "true" > else error((),"false") > > [snip2]: > == > %basex:inline(0) > %basex:lazy > function( $pred > , $true > , $false > ) > { > if ( $pred) > then $true > else $false > } ( true() > , "true" > , error((),"false") > ) > > Can you please have a look at this? > TIA. > Greatings, > Rob Stapper > PS. As I remember this used to work fine. > I remember we had a discussion concerning inlining and laziness on 2015-06-17.
Re: [basex-talk] Autocomplete with RESTXQ
Hi Gerrit, I came up with the following example — https://git.basex.io/basex-public/mailinglist-autocomplete Hope this helps — feel free to ask for more. I simply chose the first autocomplete library that showed up when asking google for "autocomplete lightweight“ ;-) Probably the most relevant changes compared to the default BaseX Config files are here: Changed the Servlet mapping, so RESTXQ is output at `/api` (and not /) > https://git.basex.io/basex-public/mailinglist-autocomplete/-/blob/main/webapp/WEB-INF/web.xml#L83 And static-files are output at: `/` instead of the default `/static` > https://git.basex.io/basex-public/mailinglist-autocomplete/-/blob/main/webapp/WEB-INF/web.xml#L140 If you simply clone my repo, the relevant parts should be „correct“ — according to my personal taste ;-) Feel free to ask for more help. Michael > Am 25.06.2020 um 18:31 schrieb Imsieke, Gerrit, le-tex > : > > Hi List, > > Can anyone recommend a lightweight vanilla Javascript autocomplete library > that can easily be used together with BaseX RESTXQ? Maybe even a readily > cloneable/modifiable example? > I don’t have a preference for a server response format. The RESTXQ service > may be configured to return XML, JSON, or HTML > No CORS restrictions need to be considered, the query host is the same that > delivers the HTML pages. > > Gerrit