简体   繁体   中英

eXist-db query: file:move returning error

I started working with eXide for my job, and i have to say that the documentation is very poor... I couldn't find a solution to this problem:

err:XPTY0004 checking function parameter 1 in call file:move($position, $destination): XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: file:move($original as item(), $destination as item()) xs:boolean. Expected cardinality: exactly one, got 0. [at line 8, column 24, source: xquery version "3.1"; import module namespace file = "http://exist-db.org/xquery/file"; let $log-in := xmldb:login('/db', 'admin', '') for $doc in collection('/db/lime-fao/fao-resolution@lime.com') let $position := document-uri($doc)[contains(., 'main.xml')] let $destination := replace($position, 'main.xml', 'main') return file:move($position,$destination)]

What am i doing wrong? Here's the query:

xquery version "3.1";
import module namespace file = "http://exist-db.org/xquery/file"; 

let $log-in := xmldb:login('/db', '*********', '*********')
for $doc in collection('/db/******/******@*****.****')
     let $position := document-uri($doc)[contains(., 'main.xml')]
     let $destination := replace($position, 'main.xml', 'main')
     return file:move($position,$destination)

Thank you.

You can try the following.

XQuery

...
let $position := base-uri($doc)[ends-with(., 'main.xml')]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM