开发者

BaseX get line-breaks return between node-data

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

xquery for $Book in 
/Libraray/开发者_如何学JAVALiteraturelist/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. ;)


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.


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), "
")


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜