xquery 输出为降价表

问题描述 投票:0回答:1

我知道如何以 HTML 格式输出 x 查询结果,参见例如 XQuery 到 HTML 表:生成列

但是我在互联网上找不到一个可以在 Markdown 表中输出的示例。 (首选 Xquery 1.0 版本)


id | lname | fname
===| ===== | =====
32 | Doe   | John
43 | Row   | Jane

我不想将 HTML 输出转换为 markdown,也不希望使用任何脚本(例如 Bash)。

到目前为止,我已经能够为 Markdown 表创建行,但不能创建表的标题


for $i in doc("source.xml")//employees
return
string-join(($i/id, $i/lname, $i/fname), "|")

我尝试按照此链接上的说明操作,但失败了。 XQuery - 是否可以生成非 XML 文档?

markdown xquery
1个回答
0
投票

所以不知何故沿着

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

declare option output:method "text";

string-join(
  (
    string-join(('id', 'last name', 'first name'), '|'),
    string-join(('--', '--', '--'), '|'),
    for $emp in //employee return string-join(($emp/id, $emp/lname, $emp/fname), '|')
  ),
  '
'
)
© www.soinside.com 2019 - 2024. All rights reserved.