问题
What does it mean "content is not allowed in prolog"? Perhaps the input method needs to be set first? I'm trying to add data to an empty database in Basex
with dummy data as below:
thufir@dur:~/flwor/people$
thufir@dur:~/flwor/people$ basex
BaseX 9.0.1 [Standalone]
Try 'help' to get more information.
> open people
Database 'people' was opened in 199.0 ms.
>
> add to people /home/thufir/flwor/people/people.txt
"/home/thufir/flwor/people/people.txt" (Line 2): Content is not allowed in prolog.
>
> exit
Have a nice day.
thufir@dur:~/flwor/people$
thufir@dur:~/flwor/people$ cat people.txt
a
1
2
3
b
4
5
6
c
7
8
9
thufir@dur:~/flwor/people$
I could make it CSV
or other, but would like to use just plain text.
Certainly it can be added through the GUI as:
Selecting the file:
回答1:
Okay, that was perhaps a silly question:
>
> list
Name Resources Size Input Path
-------------------------------------------------------------------------------
com.w3schools.books 1 6290 https://www.w3schools.com/xml/books.xml
dummy 1 21119
foo 1 167152 /home/thufir/basex/foo/foo.fodt
people 1 4610
text 1 55302 /home/thufir/Desktop/text.txt
twitter 45 366800
w3school_data 1 5209 https://www.w3schools.com/xml/note.xml
7 database(s).
> drop database people
Database 'people' was dropped.
>
> create database people
Database 'people' created in 79.03 ms.
>
> open people
Database 'people' was opened in 0.05 ms.
>
> set parser text
PARSER: text
>
> add to people /home/thufir/flwor/people/people.txt
Resource(s) added in 9.18 ms.
>
> list
Name Resources Size Input Path
-------------------------------------------------------------------------------
com.w3schools.books 1 6290 https://www.w3schools.com/xml/books.xml
dummy 1 21119
foo 1 167152 /home/thufir/basex/foo/foo.fodt
people 1 4610
text 1 55302 /home/thufir/Desktop/text.txt
twitter 45 366800
w3school_data 1 5209 https://www.w3schools.com/xml/note.xml
7 database(s).
>
> exit
Have fun.
thufir@dur:~/flwor/people$
来源:https://stackoverflow.com/questions/60237531/how-to-add-a-flat-text-file-to-basex