Hi all --
I was working with the update:apply example [1], and it throws an error: [XPTY0004] Cannot convert xs:string to node(): "doc.xml".
I'm a little confused by this: if I modify the example, and change the last to `db:add('existing-db', 'doc.xml')` (which is db:add#1, right?), it works fine. However, keeping the local:update and trying to use `db:add#1` generates another error: [XPST0017] db:add(database,input[,path[,options]]): 1 argument supplied, 2-4 expected
Would someone be able to shed some light on where this is going wrong? Thanks, Bridger
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
Christian - as always, thank you for the informative response.
On Mon, Feb 26, 2018 at 6:10 AM, Christian Grün christian.gruen@gmail.com wrote:
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 formal term is much appreciated :).
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')
And, this notation is Really Cool - more neat stuff to try getting my head
around.
(: 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,
Absolutely!
Christian
Cheers, Bridger
basex-talk@mailman.uni-konstanz.de