I recently took over an older code project for a new job, and this project extensively uses XML databases stored in BaseX. The core project is a Node web application delegating various database operations to XQuery functions interacting with the BaseX databases.
Recently, an external API that we were using to cross-publish our public data (a sort of public data hub) completely changed its API, and only accepts JSON encoding for its REST API calls. This is a problem for us, because we were using our BaseX/XQuery methods to shape XML-encoded REST calls and it worked really well.
I looked thoroughly at the documentation for various modules of BaseX (JSON & HTTP modules in particular) but it does seem like XML elements are the only things accepted by the http:send-request
function we are using to make our calls in XQuery. BaseX is apparently able to parse and serialize JSON data but I could not find anything to send JSON data for HTTP requests.
I was thinking of performing this external publication in the Node app code instead of the XQuery methods, but the contents of the publication are relying on various data fetched from the database, so it does feel a little counter-productive.
Am I missing something here? Is it possible to use XML data from BaseX databases to shape and send JSON data in XQuery?
Thanks in advance.