Hi all,
Happy new year btw!
I got bitten by something and can't explain this behaviour.
So the situation is that I have an XML file on the file system in F:/tmp/foo.xml
I also have this file imported into a database named "foo" (and the path "/foo.xml".
Now in the GUI (and on 8.5.3) I have the following.
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? Also db:* functions also get a database node from the latter and return a node-id for example.
When the foo.xml is moved to another filesystem directory then this doesn't happen so it appears as if this happens only when I try to read the file from the original import location.
Shouldn't these two situations have the same result?
Cheers, --Marc
... am I missing something?
So this
db:node-id($node)
should raise an error in case $node is not a database node. However in the GUI and in the command-line client.
db:node-id(doc('F:/tmp/afile.xml')) => 0 db:node-id(doc('F:/tmp/afile.xml')/*) => 1
only requirement is that 'F:/tmp/afile.xml' exists as a file. Even with no database open or existing and never having imported this file.
It doesn't depend on the format of the path and same result with 'F:\tmp\afile.xml', 'file:///F:/tmp/afile.xml'.
--Marc
On Tue, Jan 10, 2017 at 3:17 PM, Marc van Grootel marc.van.grootel@gmail.com wrote:
Hi all,
Happy new year btw!
I got bitten by something and can't explain this behaviour.
So the situation is that I have an XML file on the file system in F:/tmp/foo.xml
I also have this file imported into a database named "foo" (and the path "/foo.xml".
Now in the GUI (and on 8.5.3) I have the following.
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? Also db:* functions also get a database node from the latter and return a node-id for example.
When the foo.xml is moved to another filesystem directory then this doesn't happen so it appears as if this happens only when I try to read the file from the original import location.
Shouldn't these two situations have the same result?
Cheers, --Marc
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
Hi Christian,
Couldn't repro it with a command script, it got the expected behaviour each way I tried. However, I can repro it consistently in the GUI.
GUI:
1. Create a new database 2. 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
- 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
basex-talk@mailman.uni-konstanz.de