我是一名数字档案管理员,最近被一家新组织聘用。结果他们的一个非常关键的数据库在 1.5/2 年前出现故障,我一直在帮助他们恢复并运行它。数据库使用exist-DB。我已经把所有东西都准备好了,除了最后一件……打印盒子/文件夹标签。这是处理该问题的代码片段:
declare function arc3:view($form) as xs:string*
{
(: let $real-user1 := session:get-attribute("user")
let $real-password := session:get-attribute("password")
let $new := session:set-current-user($real-user1, $real-password)
:)
let $s := arc3log:add-log-message("at top of local view")
let $file-name := $form/data/file
let $short-name := $form/data/shortTitle
(: let $current := xmldb:get-current-user()
let $temp := concat($current,"-temp-file.xml")
let $d := xmldb:store("/db/apps/archives3/data/", $temp, $form)
let $tempFile := concat("/db/apps/archives3/data/",$temp)
let $rec := util:eval("doc($tempFile)")
:)
let $rec := $form
let $rec := transform:transform($rec, "xmldb:exist:///apps/archives3/resources/styles/printLabel.xsl", <parameters><param name="filename" value="{$file-name}"/></parameters>)
let $query := if($form/data/type='folder') then concat($rec, "order by number($f/did/container[@type='box']),number($f/did/container[@type='folder']) return <folder><box>{$f/did/physloc/text()}</box><folderNumber>{$f/did/container[@type='folder']/text()}</folderNumber><folderTitle>{$f/did/unittitle/text()}</folderTitle><date1>{$f/did/unitdate/text()}</date1><Accession>{$f/acqinfo/p/num/text()}</Accession><Title>{$f/ancestor::ead/archdesc/did/unittitle[@type='short']/text()}</Title></folder>") else concat($rec,") order by number($boxes) return for $box in $boxes let $date2 := if (doc('",$file-name,"')/ead//dsc//container[.[@type='box'] = $box]/../unitdate/string-length(@normal) > 4) then max(doc('",$file-name,"')/ead//dsc//container[.[@type='box'] = $box]/../unitdate/substring(@normal,6)) else max(doc('",$file-name,"')/ead//dsc//container[.[@type='box'] = $box]/../unitdate/substring(@normal,1,4))
let $date3 := min(doc('",$file-name,"')/ead//dsc//container[.[@type='box'] = $box]/../unitdate/substring(@normal,1,4)) let $f := doc('",$file-name,"')/ead//dsc//container[.[@type='box'] = $box][1] let $d := doc('",$file-name,"')/ead//dsc//container[.[@type='box'] = $box][last()] let $line := $f/ancestor::c[@level='series']/did/unittitle/text() let $line2 := $d/ancestor::c[@level='series']/did/unittitle/text() let $test1 := if ($date3=$date2) then <date>{$date2}</date> else <date>{$date3}-{$date2}</date> let $test2 := if ($line=$line2) then <line>{$line}</line> else <line>{$line}-{$line2}</line> return <box><accession>{$f/../../acqinfo/p/num/text()}</accession><fonds><name>{$f/ancestor::archdesc/did/origination/text()}</name></fonds> <title><prime>{$f/ancestor::archdesc/did/unittitle[1]/text()}</prime>{$test2} {$test1} </title> <container>{$d/text()}</container> <stack>{$f/../physloc/text()}</stack></box>")
let $s := arc3log:add-log-message("did transform")
let $query := if($form/data/type='box' and contains($rec,'physloc')) then concat($rec, ") order by number($boxes)
return
for $box in $boxes
let $date2 := if(max(doc('",$file-name,"')/ead//dsc//physloc[. = $box]/../unitdate/string-length(@normal) > 5) then max(doc('",$file-name,"')/ead//dsc//physloc[. = $box]/../unitdate/substring(@normal,6)) else max(doc('",$file-name,"')/ead//dsc//physloc[. = $box]/../unitdate/substring(@normal,-1,4))
let $date3 := min(doc('",$file-name,"')/ead//dsc//physloc[. = $box]/../unitdate/substring(@normal,1,4))
let $f := doc('",$file-name,"')/ead//dsc//physloc[. = $box]/../container[@type='box'][1]
let $d := doc('",$file-name,"')/ead//dsc//physloc[. = $box]/../container[@type='box'][last()]
let $line := $f/ancestor::c[@level='series']/did/unittitle/text()
let $line2 := $d/ancestor::c[@level='series']/did/unittitle/text()
let $test1 := if ($date3=$date2) then <date>{$date2}</date> else <date>{$date3}-{$date2}</date>
let $test2 := if ($line=$line2) then <line>{$line}</line> else <line>{$line}-{$line2}</line>
return <box><accession>{$f/../../acqinfo/p/num/text()}</accession><fonds><name>{$f/ancestor::archdesc/did/origination/text()}</name></fonds> <title><prime>{$f/ancestor::archdesc/did/unittitle[1]/text()}</prime>{$test2} {$test1} </title> <container>{$d/text()}</container> <stack>{$f/../physloc/text()}</stack></box>") else $query
let $s := arc3log:add-log-message(concat("this Query is: ", $query))
let $recs := util:eval($query)
let $s := arc3log:add-log-message(concat("this result is: ", $recs))
let $blank-label := if ($form/data/type="folder") then <folder xmlns="" /> else <box xmlns="" />
let $count := $form/data/startLabel
let $add := (
for $p in 1 to (xs:int($count)-1)
return $blank-label
)
let $label := if($form/data/type ="folder" ) then
<FLD xmlns="">{$add} { $recs} </FLD>
else
<boxlbl xmlns="">{$add}{$recs}</boxlbl>
let $s := arc3log:add-log-message(concat("the label is: ", $label))
let $s := if ($form/data/type ="folder") then file:serialize($label,concat("../Labels-",$short-name,".xml"), "method=xml, omit-xml-declaration=no, media-type=application/xml, indent=no")
else
file:serialize($label, concat("../Boxes-",$short-name,".xml"),"method='xml',omit-xml-declaration='no',media-type='application/xml',indent='no'")
return
if ($form/data/type ="folder") then
concat("Labels-",$form/data/shortTitle,".xml")
else
concat("Boxes-",$form/data/shortTitle,".xml")
};
它无法创建标签并给我一个错误“错误无法序列化文件。序列化节点集时出现问题:../Boxes-.xml(权限被拒绝)[第 66 行,第 33 列]在函数中:arc3 :view(item()*) [25:27:/db/apps/archives3/modules/arc3.xql]
我更新了行/列以反映我粘贴的代码片段中的位置。
任何对此的帮助将不胜感激。
错误消息中的“权限被拒绝”部分是导致此错误的关键指标。 eXist-db 的
file:serialize
函数只能由“admin”用户或“dba”组的成员调用。您需要显式调用 xmldb:login
函数(此处或在调用此 arc3:view
函数的主模块中),或者需要在该主模块上设置 sticky bit。