Op 22-02-2022 om 16:58 schreef Christian Grün:
(On close reading I see that "Session$Execute(paste("Create
db", DB_Name, Single_File))" should have been "Session$Execute(paste("Create db", DB_Name, Single_File))" The "paste() function just concatenates the strings)
Does that solve your problem?
No, this line executed without problems.
The BaseX user command CREATE DB differs from the technical CREATE command that’s defined in the server protocol. With the latter one, the optional input must be a (single) XML document. The reason is that the client usually resides on a different system than the server, and specifying a file path wouldn’t work.
!!!! That sounds better!!!
This works: Session$Create(DB_Name, "<Line_1 line='1'>Content 1</Line_1>")
"Database 'Parl_Test' gemaakt in 8.64 ms."
So you distinguish a XML-DOCUMENT from a XML-FILE and that was something I didn't know. 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?
I already have this function which checks if input is already a raw vector or if the input can be transformed into a vector. Even with limited R-knowledge this shpuld be readable ;-)
input_to_raw <- function(input) { type <- typeof(input) switch (type, "raw" = raw_input <- input, # Raw "character" = { if (input == "") { # Empty input raw_input <- raw(0) } else if (file.exists(input)) { # File on filesystem finfo <- file.info(input) toread <- file(input, "rb") raw_input <- readBin(toread, what = "raw", size = 1, n = finfo$size) close(toread) } else if (is.VALID(input)) { get_URL <- httr::GET(input) raw_input <- get_URL$content } else { # String raw_input <- charToRaw(input) } }, default = stop("Unknown input-type, please report the type of the input." ) ) return(raw_input) }
I'll see if I can use this function in Session$Create().
Feature request: Could you implement the same functionality in the server protocol?
Cheers, Ben