- Create a new database
I think this is the point where I’m stuck. Probably it’s not enough to create an arbitrary database, but the path must somewhat be similar to the path of the file that you are addressing in the next steps? Did you first create an empty database and add the document later on? Did you specify the full file path? etc..
- Point Input file or directory to an existing XML file, say,
"F:/tmp/foo.xml" (haven't verified behaviour on Mac yet) 3. Provide the db name, say, "foo" 4. Click OK 5. Execute following query in GUI: "base-uri(doc('F:/tmp/foo.xml'))" (returns /foo/foo.xml as the database is now opened) 6. Close the database 7. Execute the same query. It now returns file:///F:/tmp/foo.xml
This was on 8.5.3 and 8.4.2 (btw on 8.4.2 step 4 returned "foo/foo.xml" (without leading slash).
Thanks for the info on "database" nodes as, indeed, the description in the docs threw me off a little.
Cheers, --Marc
On Tue, Jan 10, 2017 at 5:45 PM, Christian Grün christian.gruen@gmail.com wrote:
Hi Marc,
When I have the database closed in the GUI
base-uri(doc('F:/tmp/foo.xml')) => file:///F:/tmp/foo.xml
And when I open the database "foo" from the GUI
base-uri(doc('F:/tmp/foo.xml')) => /foo/foo.xml
Is that right?
I wouldn’t say so ;) As somewhat usual, I couldn’t reproduce it that easily. Could you possibly give me a step-by-step description how to proceed? Or ideally a command script that shows the behavior?
db:node-id($node)
should raise an error in case $node is not a database node.
We should possibly switch to another naming, because "database node" is not that appropriate (anymore). The background: We have two different XML node representations in BaseX. One is object-oriented, and it’s the format used for node constructors:
db:node-id(<x/>) → error db:node-id(element x { }) → error
It’s the most efficient solution for small XML fragments.
"Database nodes" are based on a compact representation, which we use for serializing databases to disk. It is also applied to keep larger fragments in main-memory, so it is used e.g. when calling functions like doc(), or the 'update' keyword:
db:node-id(doc('bla.xml')) → 0 db:node-id(<x/> update {}) → 0
Hope this helps, Christian
-- --Marc