dev1.3, rev.9095
When a recursive patter is used in xdb:store-files-from-pattern it misses
the first directory.
Test case: In the directory where the test.xql file is located ( the code is
at the bottom of this email) create a file test-data.xml and copy it to the
following directory structure:
copy-files.xql
data/test-data.xml
data/d1/test-data.xml
data/d2/test-data.xml
We want to import these files, keeping the directory structure in the
database under a collection /db/test :
/db/test/test-data.xml
/db/test/d1/test-data.xml
/db/test/d2/test-data.xml
The result is:
/db/test/test-data.xml
/db/d1/test-data.xml
/db/d2/test-data.xml
copy-files.xql:
xquery version "1.0" encoding "UTF-8";
declare default function namespace "
http://www.w3.org/2005/xpath-functions";
import module namespace xdb="
http://exist-db.org/xquery/xmldb";
declare boundary-space strip;
declare option exist:serialize "method=xml media-type=text/xml";
let $home := system:get-exist-home()
let $pathSep := util:system-property("file.separator")
let $current-dir := replace(system:get-module-load-path(),'\\', '/')
let $dir-to-copy := 'data'
let $coll := '/db/test'
let $ping-coll := if( xdb:collection-exists ($coll)) then ()
else xdb:create-collection( '/db', 'test')
let $dir := if( contains($current-dir,':/' ) ) (: c:/eXist - windows os :)
then(
if( $dir-to-copy = '.' ) then
$current-dir
else
concat($current-dir, '/', $dir-to-copy )
)else if(ends-with($home, "WEB-INF")) then
concat(substring-before($home, "WEB-INF"), $coll, $pathSep, $dir-to-copy )
else
concat($home, $pathSep, "webapp", $pathSep, $coll, $pathSep, $dir-to-copy )
return
element root {
element path { $dir },
xdb:store-files-from-pattern( $coll, $dir, '**/*.xml', 'text/xml',
true() )
}
Regards,
Thomas
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to:
http://p.sf.net/sfu/opensolaris-get_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open