Как добавить весь файл text в базу данных с данными FLWOR
?
в people.txt:
people
joe
phone1
phone2
phone3
sue
cell4
home5
alice
atrib6
x7
y9
z10
Конечно, это выполнимо через консоль:
thufir@dur:~/flwor/foo$
thufir@dur:~/flwor/foo$ basex
BaseX 9.0.1 [Standalone]
Try 'help' to get more information.
>
> create database foo
Database 'foo' created in 260.89 ms.
>
> set parser text
PARSER: text
>
> add people.txt
Resource(s) added in 9.17 ms.
>
> xquery .
<text>
<line>people</line>
<line>joe</line>
<line>phone1</line>
<line>phone2</line>
<line>phone3</line>
<line>sue</line>
<line>cell4</line>
<line>home5</line>
<line>alice</line>
<line>atrib6</line>
<line>x7</line>
<line>y9</line>
<line>z10</line>
</text>
Query executed in 210.35 ms.
>
> exit
See you.
thufir@dur:~/flwor/foo$
, но с FLOWR
я сталкиваюсь с ошибкой пространства имен:
thufir@dur:~/flwor/foo$
thufir@dur:~/flwor/foo$ basex createDB.xq
Stopped at /home/thufir/flwor/foo/createDB.xq, 4/14:
[XPST0081] No namespace declared for 'text:parse'.
thufir@dur:~/flwor/foo$
script:
let $database := "foo"
for $name in file:list('.', false(), '*.txt')
let $file := file:read-text($name)
let $text := text:parse($file)
return db:add($database, $text, $name)