Hi,
a REST API returns data in JSON, which I have requested via the http-client's `http:send-request#1` function with the following code:
1. let $data := local:get-article($token, concat($local:ahost, $link))/json 2. let $response := json:serialize($data, map{'format':'xquery'}) 3. => json:parse(map{'format':'xquery'}) 4. let $child := $response(2)?data?children(1)?data 5. return $child?body_html
BaseX returns the JSON XML-encoded (see line 1), so I serialize once into JSON (line 2), then to XQuery Map (line 3). In line 4 I return data, that can look like this:
<div class="md"><p>Welcome everyone from <a href="/r/all">r/all</a>! Please remember:</p>
In the further process I would like this to become proper XHTML.
I tried all the different `fn:serialize#2` parameters. Either the data stays the same or it gets re-entitized. I also tried `html:parse#1` but get the error:
[html:parse] Line 1: No text allowed before root element.
I also tried casting to `xs:normalizedString` or using `fn:normalize-space#1` to no avail, before the `html:parse#1`
As last I tried
document { $child?body_html }
which did not change anything in the output.
If I do this, however:
let $data := ' <div class="md"><p>Welcome everyone from <a href="/r/all">r/all</a>! Please remember:</p>' return $data
I get this:
<div class="md"><p>Welcome everyone from <a href="/r/all">r/all</a>! Please remember:</p>
So my question is: How can I serialize this into XHTML (de-entitze it)? Thanks.