Marklogic 7,Windows 7的Marklogic - xdmp:EVAL產生錯誤,如「無效選項節點」
我想寫XQuery來改變文件使用xdmp:load
中的URI(ML的本地版本)和xdmp:delete
在單個交易中起作用。
我終於決定使用xdmp:eval
。什麼導致錯誤?
碼如下: -
for $SrcFileNode in xdmp:directory("/Abstracts/", "infinity") [position() lt 10]
(: get filename from path string :)
let $Filename := (if (fn:contains(fn:document-uri($SrcFileNode),".zip/"))
then fn:substring-after(document-uri($SrcFileNode),".zip/")
else fn:substring-after(document-uri($SrcFileNode),"Loadrecords/")
)
(: create new URI would "document{...}" be better? :)
let $newURInode := xdmp:unquote(
fn:concat('<options xmlns="xdmp:document-load"><uri>/Abstracts/'
,$Filename,'</uri><repair>none</repair><permissions>'
,xdmp:default-permissions(),'</permissions><collections><collection>'
,'Abstracts','</collection></collections></options>')
)
(: get string of node's name :)
let $SrcFileStr := xdmp:quote(fn:document-uri($SrcFileNode))
(: build a string of the copy + delete actions in a single transaction as applied to the current file. Implement the action using "xdmp:eval" :)
let $LoadDelCMD := 'xquery version "1.0-ml";
declare option xdmp:transaction-mode "update";
xdmp:document-load($SrcFileStr,$newURInode);
xdmp:document-delete($SrcFileStr);
xdmp:commit()'
(: execute the copy/delete for the current document :)
(: 1st attempt...
return xdmp:eval($LoadDelCMD,(),<options xmlns="xdmp:eval"> <isolation>different-transaction</isolation> <prevent-deadlocks>true</prevent-deadlocks></options>)
:)
(: 2nd attempt...
let $Option := document{<options xmlns="xdmp:eval"><isolation>different-transaction</isolation> <prevent-deadlocks>true</prevent-deadlocks></options>}
return xdmp:eval($LoadDelCMD,(),$Option)
:)
(: 3rd attempt...
let $Option2 := xdmp:unquote('<options xmlns="xdmp:eval"> <isolation>different-transaction</isolation> <prevent-deadlocks>true</prevent-deadlocks></options>')
return xdmp:eval($LoadDelCMD,(),$Option2)
:)
的錯誤是...... 「[1.0毫升] XDMP-INVOPTNOD:xdmp:EVAL(」 版本的XQuery 1.0 "毫升"; ...「,(),文件{<選項xmlns =「xdmp:eval」>不同交易 <預防死鎖> t ...}) - 無效選項節點:fn:doc(「」)「OR」[1.0-ml] XDMP-BADCHAR: (err:XPST0003)發現意外字符'''(0x0022) 在第3行第58列「 在第48行第8列 –
2014-09-04 09:33:26