BaseX Database Add in Java

2019-09-15 19:07发布

问题:

I am quite new to developing using the BaseX api, and I keep running into some trouble with one of the methods. I have a database created and opened, but when I try to use the Add method it throws an exception. See this page for an example from BaseX.

I have created the Database in another section of the code, and the file I am trying to add also exists on my computer. My snippet of code looks like this:

//Opens the database
new Open(databaseName).execute(context);

//adds file to database
new Add("", directoryPath + indexName + "/" + catalog.getInternalID() + ".Catalog.xml").execute(context);

The error I am getting is this:

org.basex.core.BaseXException: "~/cdsp.Catalog.xml" (Line 1): whitespace expected, attribute name found.

I do not really know what this means, when I try to add other xml files to the database they work and I have not found much googleing this exception. Any help would be much appreciated. Thanks!

回答1:

I am not sure if you are still running in this problem. Anyway it looks like your XML file contains an attribute where white space is expected. You could try opening cdsp.Catalog.xml in an editor of your choice and see what is there at line 1.

Hope this helps, Michael