Qconsole返回多个文档节点。但不知道如何将文件系统中的所有文档节点保存到单个xml文件中。我不知道为什么它只保存最后一个文件。 ; - ((提前致谢。
我的示例源代码。
(:validate condition and concate values:)
declare function local:ifx($mnem,$val) as node()* {
if(fn:exists($val))
then xdmp:value(fn:concat("<meta name=""{$mnem}"" content=""",$val,""" />"))
else ()
};
(:Loop and concat values:)
declare function local:forx($mnem,$vals) as node()* {
for $val in $vals
return xdmp:value(fn:concat("<meta name=""{$mnem}"" content=""",$val,""" />"))
};
declare function local:ETL($nodes as node()*) as node()*{
for $n in $nodes
let $v_id := $n/rec:record/meta:Metadata/meta:id
let $v_ba := for $elem in $n/rec:record/meta:Metadata/meta:fundingSource
return if (fn:string-length($elem/meta:BugetCode/meta:code)= 1)
then fn:concat("0",$elem/meta:BugetCode/meta:code)
else $elem/meta:BugetCode/meta:code
return
<record url="dbfeed.iadb" mimetype="text/html" last-modified="NA">
<metadata>
{local:ifx("id",$v_id)}
{local:forx("ba",$v_ba)}
</metadata>
</record>
)
};
(:find all documents within a year:)
let $docs := cts:search(
fn:doc(),
cts:and-query((
cts:element-value-query(xs:QName("meta:Collection"),"EDS"),
cts:field-range-query("rd",">=","2016-01-01"),
cts:field-range-query("rd","<","2017-01-01")
))
)
let $XML2016 :=
for $i in (local:uredetl($docs))
return $i
return xdmp:save("/output/all-data-2016.xml") ,$XML2016)