Hi all -
I'm trying to keep track of some HTTP POST results in a file, something
akin to the following:

file:write-text(
  "/tmp/bridger-test.csv",
  "book" || "," || "title" || "," || "sip" || out:nl()
),

for $i in 1 to 20
(: some http:send-request stuff :)
return(
  prof:sleep(250),
  if ($request[1]//@status/data() = 201)
  then file:append(
    "/tmp/bridger-test.csv",
    "book: " $i || "," || "title: " $i || "," || ""
  )
  else "something went wrong with the request; the response was: " ||
$request[1]//@status/data()

I have something that kinda works, but I'd like it to be better XQuery,
avoid the two step create-file-then-append, and leverage more of built-in
awesomeness in the language. I'm sure that I need to have a better
understanding of the Update syntax, and/or %updating annotation, but would
someone be willing to give some hints and/or suggestions for a better way
to handle situations like this?
Thanks in advance for your time and trouble.
Best,
Bridger

Reply via email to