And naturally I forgot to mention...
On Sun, Oct 11, 2020 at 3:49 PM Bridger Dyson-Smith <[email protected]>
wrote:

> Hi all -
>
> I'm accustomed to writing something like the following:
>
> ```xquery
>
> declare function local:grab(
>   $url as xs:string,
>   $path as xs:string,
>   $fname as xs:string
> ) as document-node() {
>   let $req := http:send-request(<http:request method="get"/>, $url)
>   return
>     if (head($req)/@status = "200")
>     then file:write($path || $fname, tail($req), map { "method": "xml" })
>     else ("something went wrong!")
> };
> ```
>
> but I've noticed that in version 9.4.3 this returns an  XPTY error:
> Stopped at /home/bridger/bin/basex-src/basex-943-xpty0004-error.xq, 1/18:
> [XPTY0004] Cannot promote xs:string* to document-node(): (let $req_7 :=
> http:send-request(<http:request method="get"/>, "
> https://dpla.lib.utk.edu/repox/OAIHa....
>
> that despite the error, the correct response is written to the filepath
specified.

While this could be a bug, should I be writing this kind of local function
> differently? Or could I improve my typing on it?
>
> Thanks very much for any advice or insights you can provide.
>
Apologies for the omission!


> Best,
> Bridger
>

Reply via email to