Hi Bridger,
> I was working with the update:apply example [1], and it throws an error:
> [XPTY0004] Cannot convert xs:string to node(): "doc.xml".
Thanks for the observation. A wrong static type for db:add was
specified in the BaseX code; this is why you got the misleading error
message (one rewriting step failed). It is working now in the latest
version of BaseX [1].
> `db:add('existing-db', 'doc.xml')` (which is db:add#1, right?), it works
> fine.
If the "#" character is used, a »named function reference« will be
created for the given function and the given number of arguments.
db:add#1 indicates that the function item, which is created for the
db:add function, can be invoked with 1 argument later on.
The following variants (and surely various others) can be used to invoke db:add:
(: Simple function call :)
db:add('existing-db', 'doc.xml')
(: Named function reference :)
updating db:add#2('existing-db', 'doc.xml')
(: Partially applied function :)
updating db:add(?,?)('existing-db', 'doc.xml')
(: Function item :)
updating function($db, $doc) {
db:add($db, $doc)
}('existing-db', 'doc.xml')
The leading 'updating' keyword is required to indicate that the
function item to be called is updating.
Hope this helps,
Christian
[1] http://files.basex.org/releases/latest/