Op 22-02-2022 om 18:39 schreef Christian Grün:
So you distinguish a XML-DOCUMENT from a XML-FILE and that was something I didn't know.
I guess so. Do we use these two terms in our documentation?
I don't know. If I find places where it is confusing (at least for me), I'll let you know
Or did you
want to point out that you used “document” and “files” for describing the same thing in our conversation?
No, they are different. A 'file' lives on the file-system (and a file-pointer points to a file). A 'document' however lives in the memory. It can for example be a string which is constructed by Xquery by adding elements or attributes to the result of a query or by writing valid xml-code with a text-editor. I thought that the client could deal with both files and documents.
Are there more places in the server protocol where this difference is relevant? Could you please make a note of this in the documentation for the server protocol?
We’ll be glad to improve the documentation. I’m not sure which of the formulations were misleading to you, so feel free to share them with us.
From the server protocol (https://docs.basex.org/wiki/Server_Protocol) Command Protocol
The following byte sequences are sent and received from the client (please note that a specific client may not support all of the presented commands): Command Client Request Description COMMAND {command} Executes a database command. QUERY \00 {query} Creates a new query instance and returns its id. CREATE \08 {name} {input} Creates a new database with the specified input (may be empty). ADD \09 {name} {path} {input} {Adds a new resource to the opened database. REPLACE \0C {path} {input} Replaces a resource with the specified input. STORE \0D {path} {input} Stores a binary resource in the opened database.
Everywhere where you use 'input', It is unclear what is valid input, a file or a document?
I already have this function which checks if input is already a raw
vector or if the input can be transformed into a vector.
Is "raw vector" a byte array or something else? What does is.VALID do?
A raw vector is a Bytearray. is.Valid is a set of regular expressions. It checks if a URL is valid (https://asf.dfg.dfhg/ is valid. htp:/ery/ery is not). In R, before being able to read from the URL (httr::GET(input)) I had to check wether the URL was valid.
Feature request: Could you implement the same functionality in the server protocol?
I’m hesitant to change the server protocol at this stage, as almost all other client bindings are based on the current definitions, and would possibly need to be updated. But maybe you need to get more specific in your wording (or it’s my task to spend more time and find out what you mean):
The "protocol" is the set of rules that are implemented by the various bindings to communicate with the server. If you say we should implement the functionality in the protocol, would you like to see new rules added? Or would you expect the server-side implementation of the protocol rules to check if the input for a CREATE command can be interpreted as file reference?
I understand. I don't believe you really have to update the protocol. It is only the client that needs to be updated.
As said before, I consistenly use this pattern: exec <- c(as.raw(0x08), addVoid(name), addVoid(input))
It took me 2 minutes to change this into: raw_input <- input_to_raw(input) exec <- c(as.raw(0x08), addVoid(name), addVoid(raw_input))
Now I can use session$Create() with a document, an URL or a file-descriptor.
(Writing a test took half an hour ;-()
I think we shouldn’t resolve client file references on the server, as clients and servers usually reside on different machines. You can provide file paths with CREATE DB, but the only reason is that this command was initially designed to work with the standalone version of BaseX. We even had thoughts on rejecting local file references if they are passed on by a client.
I think BaseX is an excellent standalone tool for xquery and xml-related applications...
Hope this helps,
Cheers, Ben