[xquery-talk] say how to get "newline" working

jidanni at jidanni.org jidanni at jidanni.org
Sat Mar 10 15:47:57 PST 2012

All I know is using
$ cat file.xq
(: Make bus timetable going westbound past Zaokeng :)
declare option db:parser "html";
declare option output:method "html"; (: etc., not poorly supported
"text" though :)
declare function local:d($M){
  doc(concat("http://www.fybus.com.tw/data/", $M))
let $line:=("1/067b.htm","city/90.htm","city/207.htm", "city/259.htm", "city/267.htm")
let $name:=("6572","  90"," 207", " 259", " 267")
let $correction:=(23,4,23,2,29)
for $l at $c in $line, $i in distinct-values(local:d($l)//*:tr/*:td[position()=2 and contains(.,":")])
let $t := xs:time(concat($i, ':00')) + xs:dayTimeDuration('PT1M') * $correction[$c]
order by $t
return <TD>{if(contains($l,"259") or (contains($l,"90")and contains($i,":00")))then "平"
else "每",substring(string($t), 1, 5),

I need to convert to text mode by hand:
$ basex file.xq|perl -pwle 's/<[^>]+>//g'
As all text serialization in Xquery can't deal with the same line
concept... unless one hardwires the line separators (0x0A) in via
string-join, which doesn't sound much like serialization to me.

More information about the talk mailing list