BaseX 获取节点数据之间的换行符返回

发布于 2024-09-06 13:35:18 字数 278 浏览 1 评论 0原文

我使用 BaseX 作为我的基于 XML 的数据库。我做了一个简单的查询,就像

xquery for $Book in 
/Libraray/Literaturelist/Literature/Title return fn:data($Book)

我得到所有标题一样,就像一个没有换行符的字符串一样。

有没有办法在查询找到的每个节点后使用 XQuery 添加换行符来分隔数据?这并不真正依赖于我的 XML 文件,因为我没有在标签内添加硬编码的换行符。 ;)

I'm using BaseX as my XML based DB. I make a simple query like

xquery for $Book in 
/Libraray/Literaturelist/Literature/Title return fn:data($Book)

I get all titles, just as a String that has got no line breaks.

Is there a way to add line-breaks with XQuery after each node found by the query to separate the data? This is not really dependant on my XML file because I do not add line-breaks hardcoded within the tags. ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倦话 2024-09-13 13:35:18

这取决于您如何检索查询结果。最优雅的方法是使用迭代器,例如:

http://basex.org/code/QueryExample

除此之外,您可以通过返回附加换行符来扩展 XQuery:

xquery for $Book in /Libbraray/Literaturelist/Literature/Title
return (fn:data($Book), '
')

但是请注意,附加输出空格字符不能被抑制。

最好的,
Christian

PS:请随意使用 Basex-talk 邮件列表来更快地获得反馈。

it depends on how you retrieve the query results. The most elegant way is to use the iterator, as e.g. shown in:

http://basex.org/code/QueryExample

Apart from that, you could extend your XQuery by returning an additional newline:

xquery for $Book in /Libbraray/Literaturelist/Literature/Title
return (fn:data($Book), '
')

Note, however, that the additionally output space character cannot be suppressed.

Best,
Christian

PS: feel free to use the basex-talk mailing list to get feedback more quickly.

深居我梦 2024-09-13 13:35:18

添加换行符的另一种方法是显式使用换行符的字符引用:

xquery for $Book in /Libbraray/Literaturelist/Literature/Title
return (fn:data($Book), "
")

Another way to add a newline is to explicitly use the character reference for a newline:

xquery for $Book in /Libbraray/Literaturelist/Literature/Title
return (fn:data($Book), "
")
自由如风 2024-09-13 13:35:18

XQuery 3.1 序列化规范提供了新的“自适应” " 序列化模式,在新行上输出每个 XQuery 结果。从 BaseX 8 开始,此模式被用作新的默认模式。

The XQuery 3.1 Serialization specification provides the new "adaptive" serialization mode, which outputs each XQuery result on a new line. Since BaseX 8, this mode is used as new default.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文