Thank you Martin! I used output method "xhtml". After changing it to "html" the string was not escaped any longer. Great!

Best regards,
Kristian Kankainen

On 7. Dec 2021, at 11:27, Martin Honnen <martin.honnen@gmx.de> wrote:


Am 07.12.2021 um 10:00 schrieb Kristian Kankainen:
Hi all,

Can I somehow control the serialization of element contents? I want to use Xquery to generate parts of source code for javascript and put the generated code inside a script element on the webpage. Basically this:

define function web:display-graph($term) {
    <script>
    {
    string-join((
      'd3.select("#graph").graphviz().renderDot(',
      "'digraph  {a -> b}'",
      ');'
      ), out:nl())
    }
    </script>
}

But it doesn't work as the > character gets replaced with its corresponding HTML entity &gt;. Is there a way to circumvent this behaviour?


At which point or how/where do you serialize that "script" element? With
output method "html" the escaping should not take place.