将每个XQuery结果放在新行上 [英] Put each XQuery result on a new line

查看:153
本文介绍了将每个XQuery结果放在新行上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可能把每个XQuery结果放在一个新行上?我以为我记得文件开头有一个属性,但是不记得了。 :

我有这个.xq文件:

$ $ p $ 声明默认元素命名空间http://www.w3.org/2001/XMLSchema; :)
在$ i在doc(zoo.xml)中// $ animal
return< ;李> {$ I}。 {$ X /名称/文本()}< /锂>

我得到正确的结果,但所有这些都在一行上,当我真的想要类似:

 < li> 1。宙斯< /锂> 
< li> 2。佛瑞德< /锂>
...

这可能吗?在此先感谢您的答案! :)

解决方案

...您可以添加一个换行符作为return子句的第二部分:

 (:declare default element namespacehttp://www.w3.org/2001/XMLSchema; :) 
for $ x at $ i in doc(zoo.xml)// animal
return(< li> {$ i}。{$ x / name / text()}< / li> ;,'& #xa ;')

结果序列化的方式也取决于特定的XQuery处理器。


Is it possible to put each XQuery result on a new line? I thought I remembered there was an attribute to set at the beginning of the document, but can't remember. :/

I have this .xq file:

(: declare default element namespace "http://www.w3.org/2001/XMLSchema"; :)
for $x at $i in doc("zoo.xml")//animal
return <li>{$i}. {$x/name/text()}</li> 

I get correct results, but all of them are on a single line, when I really want something like:

<li>1. Zeus</li>
<li>2. Fred</li>
...

Is this possible? Thanks in advance for your answers! :)

解决方案

...you can add a newline string as second part of the return clause:

(: declare default element namespace "http://www.w3.org/2001/XMLSchema"; :)
for $x at $i in doc("zoo.xml")//animal
return (<li>{$i}. {$x/name/text()}</li>, '&#xa;')

The way how results are serialized also depends on the specific XQuery processor.

这篇关于将每个XQuery结果放在新行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆