Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import-and-process.xq
- import module namespace acs = 'http://whatever.net' at 'lib.xqm';
- declare variable $filename external;
- acs:import-and-process($filename)
- import-all.xq
- import module namespace acs = 'http://whatever.net' at 'lib.xqm';
- declare variable $dir external;
- (:
- : for-each(file:list($dir, xs:boolean("false"), "*.xml"), acs:import-and-process(?))
- :)
- for $file in file:list($dir, xs:boolean("false"), "*.xml")
- return acs:import-and-process(file:current-dir() || $dir || '\' || $file)
- lib.xqm
- module namespace acs = 'http://whatever.net';
- declare function acs:hello($world) {
- 'Hello' || $world
- };
- declare updating function acs:import-and-process($filename) {
- (: find timestamp in filename :)
- (: get package and file into variables :)
- let $mydoc := doc($filename)
- let $datetime := file:last-modified($filename)
- let $package := substring-before($mydoc/testrun/testsuite/@name/data(), ".")
- let $file := substring-after($mydoc/testrun/testsuite/@name/data(), ".")
- let $testrun := file:name($filename)
- (: add file to database :)
- (: insert package, file, and timestamp attributes to every testcase :)
- return
- copy $mycopy := $mydoc
- modify (for $testcase in $mycopy//testcase
- return insert nodes
- (attribute package {$package},
- attribute file {$file},
- attribute xs:datetime {$datetime},
- attribute testrun {$testrun})
- into $testcase)
- return
- (db:replace("TestResults", file:name($filename), $mycopy)),
- (db:flush("TestResults"))
- };
- basex -i TestResults -b dir=TestResults import-all.xq
- : Updates are not written back.
Advertisement
Add Comment
Please, Sign In to add comment