1
votes

I would like to develop a web application using Basex as a backend and Bootstrap HTML framework as a frontend. Bootstrap's example "navbar-fixed" shows that the webpage should contain in it's source the fragment:

<script>window.jQuery || document.write('<script src="/docs/4.5/assets/js/vendor/jquery.slim.min.js"><\/script>')</script>

I tried many ways to return such a string from XQuery function but I failed. For example:

declare function template:page() {
      <script>window.jQuery || document.write( '<script src="/docs/4.5/assets/js/vendor/jquery.slim.min.js"><\/script>' )</script>
};

does not compile and gives an error "Expecting element name, '<' found". On the other hand:

declare function template:page() {
      <script>window.jQuery || document.write( { '<script src="/docs/4.5/assets/js/vendor/jquery.slim.min.js"><\/script>' } )</script>
};

escapes chars and gives the wrong output:

<script>window.jQuery || document.write( &lt;script src="/docs/4.5/assets/js/vendor/jquery.slim.min.js"&gt;&lt;\/script&gt; )</script>

Is there a way to achieve the needed effect?

Best regards

1

1 Answers

1
votes

In XML you can use CDATA sections e.g.

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'html';
declare option output:html-version '5.0';

<script><![CDATA[window.jQuery || document.write( '<script src="/docs/4.5/assets/js/vendor/jquery.slim.min.js"><\/script>' )]]></script>