Cannot insert node into empty db/collection
Thursday, 6 October 2016 · 6 messages
EK
Erdal Karaca6 Oct 2016 18:03 #
Hi,
When creating an empty database, then trying to insert a node into its root, I get the following error message:
Command:
create db test
XQuery:
insert node <test></test> into /
Error:
[XUDY0027] Insert target is an empty sequence.
How can I populate an empty database? - I am using basex 8.5.3.
Thanks!
DK
Dirk Kirsten6 Oct 2016 18:29 #
Hello Erdal,
a database consists of (multiple) documents. When you create a database with the given command it will be en empty database without any document. So to write into it you will have to add at least one document first, e.g. by using the ADD command
(http://docs.basex.org/wiki/Commands#ADD) or
db:add()
(http://docs.basex.org/wiki/Database_Module#db:add)
Cheers
DirkQuoted text · Erdal Karaca · 17 lines
On 10/06/2016 06:03 PM, Erdal Karaca wrote: > Hi, > When creating an empty database, then trying to insert a node into its > root, I get the following error message: > > Command: > create db test > > XQuery: > insert node <test></test> into / > > Error: > [XUDY0027] Insert target is an empty sequence. > > How can I populate an empty database? - I am using basex 8.5.3. > > Thanks!
--
Dirk Kirsten, BaseX GmbH, http://basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22
EK
Erdal Karaca6 Oct 2016 19:19 #
Hi Dirk,
Thanks for the answer!
When creating the database, I do not know what the root of the document to create will be.
Also, I do not have any physical documents (xml files) to add initially as the root elements will be created programmatically (basex embedded mode). the
db:add() command needs an initial input: Is there a way to create an empty document?
Thanks.
2016-10-06 18:29 GMT+02:00 Dirk Kirsten <dk at basex.org>:Quoted text · Dirk Kirsten · 38 lines
> Hello Erdal, > > a database consists of (multiple) documents. When you create a database > with the given command it will be en empty database without any > document. So to write into it you will have to add at least one document > first, e.g. by using the ADD command > (http://docs.basex.org/wiki/Commands#ADD) or db:add() > (http://docs.basex.org/wiki/Database_Module#db:add) > > Cheers > Dirk > > On 10/06/2016 06:03 PM, Erdal Karaca wrote: > > Hi, > > When creating an empty database, then trying to insert a node into its > > root, I get the following error message: > > > > Command: > > create db test > > > > XQuery: > > insert node <test></test> into / > > > > Error: > > [XUDY0027] Insert target is an empty sequence. > > > > How can I populate an empty database? - I am using basex 8.5.3. > > > > Thanks! > > -- > Dirk Kirsten, BaseX GmbH, http://basexgmbh.de > |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 > >
DK
Dirk Kirsten6 Oct 2016 19:37 #
Hello Erdal,
an XML document has to have at least one (root) element, otherwise it isn't a well-formed XML document. This is specified by the W3C, see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-well-formed: " A textual object is a *well-formed* XML document if [...] it contains one or more elements.". So, nothing we can do about this :)
But you can create a simple document with a lonely root node to later put content into. E.g. you could execute the following query:
db:add("test", <root/>, "doc.xml")which creates the well-formed XML document doc.xml with the root element <root/> in your test database.
Hope this helps
Dirk
Quoted text · Erdal Karaca · 60 lines
On 10/06/2016 07:19 PM, Erdal Karaca wrote: > Hi Dirk, > Thanks for the answer! > When creating the database, I do not know what the root of the > document to create will be. > Also, I do not have any physical documents (xml files) to add > initially as the root elements will be created programmatically (basex > embedded mode). > the db:add() command needs an initial input: Is there a way to create > an empty document? > > Thanks. > > 2016-10-06 18:29 GMT+02:00 Dirk Kirsten <dk at basex.org > <mailto:dk at basex.org>>: > > Hello Erdal, > > a database consists of (multiple) documents. When you create a > database > with the given command it will be en empty database without any > document. So to write into it you will have to add at least one > document > first, e.g. by using the ADD command > (http://docs.basex.org/wiki/Commands#ADD > <http://docs.basex.org/wiki/Commands#ADD>) or db:add() > (http://docs.basex.org/wiki/Database_Module#db:add > <http://docs.basex.org/wiki/Database_Module#db:add>) > > Cheers > Dirk > > On 10/06/2016 06:03 PM, Erdal Karaca wrote: > > Hi, > > When creating an empty database, then trying to insert a node > into its > > root, I get the following error message: > > > > Command: > > create db test > > > > XQuery: > > insert node <test></test> into / > > > > Error: > > [XUDY0027] Insert target is an empty sequence. > > > > How can I populate an empty database? - I am using basex 8.5.3. > > > > Thanks! > > -- > Dirk Kirsten, BaseX GmbH, http://basexgmbh.de > |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > `-- Phone: 0049 7531 91 68 276 <tel:0049%207531%2091%2068%20276>, > Fax: 0049 7531 20 05 22 <tel:0049%207531%2020%2005%2022> > >
--
Dirk Kirsten, BaseX GmbH, http://basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22
CG
Christian Grün6 Oct 2016 19:41 #
+1 for Dirk’s answer. One more thing: You can create a single root node along with your CREATE DB call:
create db test <root/>
Quoted text · Dirk Kirsten · 83 lines
On Thu, Oct 6, 2016 at 7:37 PM, Dirk Kirsten <dk at basex.org> wrote: > Hello Erdal, > > an XML document has to have at least one (root) element, otherwise it isn't > a well-formed XML document. This is specified by the W3C, see > https://www.w3.org/TR/2008/REC-xml-20081126/#sec-well-formed: " A textual > object is a well-formed XML document if [...] it contains one or more > elements.". So, nothing we can do about this :) > > But you can create a simple document with a lonely root node to later put > content into. E.g. you could execute the following query: > > db:add("test", <root/>, "doc.xml") > > which creates the well-formed XML document doc.xml with the root element > <root/> in your test database. > > > Hope this helps > > Dirk > > > On 10/06/2016 07:19 PM, Erdal Karaca wrote: > > Hi Dirk, > Thanks for the answer! > When creating the database, I do not know what the root of the document to > create will be. > Also, I do not have any physical documents (xml files) to add initially as > the root elements will be created programmatically (basex embedded mode). > the db:add() command needs an initial input: Is there a way to create an > empty document? > > Thanks. > > 2016-10-06 18:29 GMT+02:00 Dirk Kirsten <dk at basex.org>: >> >> Hello Erdal, >> >> a database consists of (multiple) documents. When you create a database >> with the given command it will be en empty database without any >> document. So to write into it you will have to add at least one document >> first, e.g. by using the ADD command >> (http://docs.basex.org/wiki/Commands#ADD) or db:add() >> (http://docs.basex.org/wiki/Database_Module#db:add) >> >> Cheers >> Dirk >> >> On 10/06/2016 06:03 PM, Erdal Karaca wrote: >> > Hi, >> > When creating an empty database, then trying to insert a node into its >> > root, I get the following error message: >> > >> > Command: >> > create db test >> > >> > XQuery: >> > insert node <test></test> into / >> > >> > Error: >> > [XUDY0027] Insert target is an empty sequence. >> > >> > How can I populate an empty database? - I am using basex 8.5.3. >> > >> > Thanks! >> >> -- >> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >> > > > -- > Dirk Kirsten, BaseX GmbH, http://basexgmbh.de > |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22
EK
Erdal Karaca6 Oct 2016 19:58 #
I will apply the dummy root node solution.
Thanks to you both!
2016-10-06 19:41 GMT+02:00 Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 95 lines
> +1 for Dirk’s answer. One more thing: You can create a single root > node along with your CREATE DB call: > > create db test <root/> > > > > On Thu, Oct 6, 2016 at 7:37 PM, Dirk Kirsten <dk at basex.org> wrote: > > Hello Erdal, > > > > an XML document has to have at least one (root) element, otherwise it > isn't > > a well-formed XML document. This is specified by the W3C, see > > https://www.w3.org/TR/2008/REC-xml-20081126/#sec-well-formed: " A > textual > > object is a well-formed XML document if [...] it contains one or more > > elements.". So, nothing we can do about this :) > > > > But you can create a simple document with a lonely root node to later put > > content into. E.g. you could execute the following query: > > > > db:add("test", <root/>, "doc.xml") > > > > which creates the well-formed XML document doc.xml with the root element > > <root/> in your test database. > > > > > > Hope this helps > > > > Dirk > > > > > > On 10/06/2016 07:19 PM, Erdal Karaca wrote: > > > > Hi Dirk, > > Thanks for the answer! > > When creating the database, I do not know what the root of the document > to > > create will be. > > Also, I do not have any physical documents (xml files) to add initially > as > > the root elements will be created programmatically (basex embedded mode). > > the db:add() command needs an initial input: Is there a way to create an > > empty document? > > > > Thanks. > > > > 2016-10-06 18:29 GMT+02:00 Dirk Kirsten <dk at basex.org>: > >> > >> Hello Erdal, > >> > >> a database consists of (multiple) documents. When you create a database > >> with the given command it will be en empty database without any > >> document. So to write into it you will have to add at least one document > >> first, e.g. by using the ADD command > >> (http://docs.basex.org/wiki/Commands#ADD) or db:add() > >> (http://docs.basex.org/wiki/Database_Module#db:add) > >> > >> Cheers > >> Dirk > >> > >> On 10/06/2016 06:03 PM, Erdal Karaca wrote: > >> > Hi, > >> > When creating an empty database, then trying to insert a node into its > >> > root, I get the following error message: > >> > > >> > Command: > >> > create db test > >> > > >> > XQuery: > >> > insert node <test></test> into / > >> > > >> > Error: > >> > [XUDY0027] Insert target is an empty sequence. > >> > > >> > How can I populate an empty database? - I am using basex 8.5.3. > >> > > >> > Thanks! > >> > >> -- > >> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de > >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > >> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > >> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 > >> > > > > > > -- > > Dirk Kirsten, BaseX GmbH, http://basexgmbh.de > > |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > > |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > > | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > > `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >
Written for BaseX 8.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery