如何更改XQuery响应的Content-Type?

时间:2016-06-27 19:33:54

标签: xquery xforms exist-db

添加图片而不是代码,因为它不会显示。

  1. 我有一个形成网页的xquery。它运行在exists-db。
  2. 此xquery使用xforms提交调用另一个xquery:

    enter image description here

  3. returnTable.xq直接从浏览器运行时返回HTML表格

    enter image description here

  4. 在这种情况下,Content-Type的响应是:     enter image description here

    1. 您可以在提交中看到此HTML表格应该替换表格中的数据'实例

    2. 它确实替换了数据,但是我得到的是纯文本而不是HTML表格。 我用 <xf:output value="instance('table')" mediatype="xhtml"/> 在网页上显示表格。我尝试了mediatype xml,text / xml等。

    3. 因此,当它被替换时,我在网页上得到了纯文本而不是HTML表格。

      enter image description here

      应该是这样的(我以完全不同的方式获得,但由于性能不佳而不想使用它):

      enter image description here

      我认为这是因为响应的内容类型是Content-Type = text/javascript Content-Type = text/xml的实例:

      enter image description here

      enter image description here

      你知道我怎么能改变这个?

1 个答案:

答案 0 :(得分:2)

您正在寻找XQuery序列化选项,supported by eXist DB,但XQuery 1.0和XQuery 3.0之间存在差异。

XQuery 1.0选项,用于将内容类型设置为application/xhtml+xml

declare option exist:serialize "method=xml media-type=application/xhtml+xml";

对于XQuery 3.0,您可以使用标准的XQuery序列化选项:

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "xml";
declare option output:media-type "application/xhtml+xml";