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@gmail.com>:
+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@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@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