While I can certainly output the result to a file, and then add to a database, how would I actually send the result directly to a database?
xquery version "3.0";
<xml> { for $line in db:open("people.json")//text() return if (matches($line, "[0-9]")) then <data>{$line}</data> else <record>{$line}</record> } </xml>
Currently I'm running it like so:
thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex all.xq > all.xml thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information.
create database people.all
Database 'people.all' created in 234.74 ms.
set parser xml
PARSER: xml
add all.xml
Resource(s) added in 377.43 ms.
exit
Have fun. thufir@dur:~/flwor/people.json$
but that's a bit cumbersome.
thanks,
Thufir
Am 19.02.2020 um 14:36 schrieb thufir:
While I can certainly output the result to a file, and then add to a database, how would I actually send the result directly to a database?
xquery version "3.0";
<xml> { for $line in db:open("people.json")//text() return if (matches($line, "[0-9]")) then <data>{$line}</data> else <record>{$line}</record> } </xml>
See http://docs.basex.org/wiki/Database_Module#db:add, you seem to want
db:add("people.all",
<xml> { for $line in db:open("people.json")//text() return if (matches($line, "[0-9]")) then <data>{$line}</data> else <record>{$line}</record> } </xml>
)
that is, you simply want to pass your query result as the second argument to the db:add function.
Currently I'm running it like so:
thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex all.xq > all.xml thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information.
create database people.all
Database 'people.all' created in 234.74 ms.
set parser xml
PARSER: xml
add all.xml
Resource(s) added in 377.43 ms.
exit
Have fun. thufir@dur:~/flwor/people.json$
but that's a bit cumbersome.
thanks,
Thufir
I see what you mean by passing the query result as the second argument to the db:add function, but am getting:
[XPST0003] Expecting function argument.
A syntax problem?
xquery version "3.0";
db:add("foo.clean.xml",
<xml> { for $x in db:open("foo.txt")/text/line return $x } </xml>
On 2020-02-19 6:08 a.m., Martin Honnen wrote:
Am 19.02.2020 um 14:36 schrieb thufir:
While I can certainly output the result to a file, and then add to a database, how would I actually send the result directly to a database?
xquery version "3.0";
<xml> { for $line in db:open("people.json")//text() return if (matches($line, "[0-9]")) then <data>{$line}</data> else <record>{$line}</record> } </xml>
See http://docs.basex.org/wiki/Database_Module#db:add, you seem to want
db:add("people.all",
<xml> { for $line in db:open("people.json")//text() return if (matches($line, "[0-9]")) then <data>{$line}</data> else <record>{$line}</record> }
</xml>
)
that is, you simply want to pass your query result as the second argument to the db:add function.
Currently I'm running it like so:
thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex all.xq > all.xml thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information.
create database people.all
Database 'people.all' created in 234.74 ms.
set parser xml
PARSER: xml
add all.xml
Resource(s) added in 377.43 ms.
exit
Have fun. thufir@dur:~/flwor/people.json$
but that's a bit cumbersome.
thanks,
Thufir
Hi Thufir,
I see what you mean by passing the query result as the second argument to the db:add function, but am getting: [XPST0003] Expecting function argument.
Please take a few times to read our docs and try out the examples; I’m sure you’ll find out soon what’s the correct syntax.
Best, Christian
On Thu, Feb 20, 2020 at 12:14 PM thufir hawat.thufir@gmail.com wrote:
A syntax problem?
xquery version "3.0";
db:add("foo.clean.xml",
<xml> { for $x in db:open("foo.txt")/text/line return $x } </xml>
On 2020-02-19 6:08 a.m., Martin Honnen wrote:
Am 19.02.2020 um 14:36 schrieb thufir:
While I can certainly output the result to a file, and then add to a database, how would I actually send the result directly to a database?
xquery version "3.0";
<xml> { for $line in db:open("people.json")//text() return if (matches($line, "[0-9]")) then <data>{$line}</data> else <record>{$line}</record> } </xml>
See http://docs.basex.org/wiki/Database_Module#db:add, you seem to want
db:add("people.all",
<xml>
{ for $line in db:open("people.json")//text() return if (matches($line, "[0-9]")) then <data>{$line}</data> else <record>{$line}</record> }
</xml>
)
that is, you simply want to pass your query result as the second argument to the db:add function.
Currently I'm running it like so:
thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex all.xq > all.xml thufir@dur:~/flwor/people.json$ thufir@dur:~/flwor/people.json$ basex BaseX 9.0.1 [Standalone] Try 'help' to get more information.
create database people.all
Database 'people.all' created in 234.74 ms.
set parser xml
PARSER: xml
add all.xml
Resource(s) added in 377.43 ms.
exit
Have fun. thufir@dur:~/flwor/people.json$
but that's a bit cumbersome.
thanks,
Thufir
basex-talk@mailman.uni-konstanz.de