views:

12

answers:

1

Hi!

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. ;)

+1  A: 

Hi there,

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.

Christian