当然!我的existdb版本是2.2。
xquery version "3.0";
declare boundary-space preserve;
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace xmldb="http://exist-db.org/xquery/xmldb";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare option output:indent "yes";
import module namespace file="http://exist-db.org/xquery/file";
let $log-in := xmldb:login("/db", "admin", "admin")
for $k in (35,36,37)
let $AppletName := fn:doc(fn:concat('/db/project/AppletA_',$k,'.xml'))//APPLET/@NAME/string()
let $collection := fn:concat('xmldb:exist:/db/project/Scripts_',$k)
let $node :=(<APPLET_SCRIPTS>{
for $i in fn:doc(fn:concat('/db/project/AppletA_',$k,'.xml'))//APPLET_SERVER_SCRIPT
let $MethodName := $i/@NAME
let $MethodScript := string($i/@SCRIPT)
let $file-name := fn:concat($MethodName,'.js')
let $store := xmldb:store($collection,$file-name, $MethodScript)
return <div>{$MethodScript}</div>
}</APPLET_SCRIPTS>)
return $node
xml的一个片段是:
截图xml片段
创建的文件内容是这一行字符串:
函数 Prova() { 尝试 { var sVal = TheApplication().InvokeMethod("LookupValue","FS_ACTIVITY_CLASS","CIM_FAC18"); var recordFound = searchRecord(sVal); if(!recordFound) { this.InvokeMethod("NewRecordCustom"); this.BusComp().SetFieldValue("Class",sVal); this.BusComp().WriteRecord(); } } 捕捉(e){ 抛出(e); } 最后 { sVal = null; } }