首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将项目导入eXist-db

如何将项目导入eXist-db
EN

Stack Overflow用户
提问于 2014-03-21 05:32:06
回答 3查看 960关注 0票数 1

我对exide和exide相当陌生,所以我已经习惯了gui和菜单,以及做东西的方式。我的问题是,我已经有一个项目,一个老师从他的存在下载它,并把它作为一个.rar给我。

问题是,我想要导入该项目,使其保持与其所拥有的文件夹结构相同。我尝试通过“集合”菜单导入它,但它忽略了文件夹结构,只上传了一个文件夹中的所有文件

文件夹结构如下:

代码语言:javascript
复制
final:
-db
    -contrib
        -file
        -file
    -css
        -somecss
        -somecss
    -js
        -somejs
        -somejs
    -img
        -img1.png
-xqueryelement.xq
-xqueryelement2.xq
-htmlelement.html
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-03-21 12:05:00

如果提取出.rar文件,并且每个文件夹都包含"_ contents_ _.xml",那么您可以使用来自java客户端的恢复功能。

如果没有,则可以使用以下内容。(我还没有对代码进行测试,而是实时编写的。)从仪表板上启动eXide。以管理员身份登录,然后将下面的代码复制到ide中,然后运行它。

该代码具有从Priscilla Walmsley的FUNCTX函数模块中复制的一些函数。http://www.xqueryfunctions.com/

代码语言:javascript
复制
xquery version "3.0";

declare namespace file="http://exist-db.org/xquery/file";

(:~
 : Escapes regex special characters 
 :
 : @author  Priscilla Walmsley, Datypic 
 : @version 1.0 
 : @see     http://www.xqueryfunctions.com/xq/functx_escape-for-regex.html 
 : @param   $arg the string to escape 
 :) 
declare function local:escape-for-regex( $arg as xs:string? )  as xs:string {

   replace($arg, '(\.|\[|\]|\\|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1')
 } ;

(:~
 : The substring before the last occurrence of a delimiter 
 :
 : @author  Priscilla Walmsley, Datypic 
 : @version 1.0 
 : @see     http://www.xqueryfunctions.com/xq/functx_substring-before-last.html 
 : @param   $arg the string to substring 
 : @param   $delim the delimiter 
 :) 
declare function local:substring-before-last( $arg as xs:string?, $delim as xs:string )  as xs:string {

   if (matches($arg, local:escape-for-regex($delim)))
   then replace($arg,
            concat('^(.*)', local:escape-for-regex($delim),'.*'),
            '$1')
   else ''
 } ;

(:~
 : The substring after the last occurrence of a delimiter 
 :
 : @author  Priscilla Walmsley, Datypic 
 : @version 1.0 
 : @see     http://www.xqueryfunctions.com/xq/functx_substring-after-last.html 
 : @param   $arg the string to substring 
 : @param   $delim the delimiter 
 :) 
declare function local:substring-after-last 
  ( $arg as xs:string? ,
    $delim as xs:string )  as xs:string {

   replace ($arg,concat('^.*',local:escape-for-regex($delim)),'')
 } ;


declare function local:import($base as xs:string, $path as xs:string) {
    let $offset := fn:substring-after($path, $base)
    return
    if (file:is-directory($path))
    then
        let $created := xmldb:create-collection('/', '/')
        let $coll := for $resource in file:list($path)
                        return local:import($base, $path || '/' || $resource)
        return $path
    else 
        let $collection : = local:substring-before-last($offset, '/')
        let $resource : = local:substring-after-last($offset, '/')
        let $stored := xmldb:store($collection, $resource, 
                                file:read-binary($path), 'application/octet-stream')
        let $permission := if (fn:ends-with($resource, ".xq")) 
                           then sm:chmod($collection || '/' || $resource, 'rwxr-xr-x')
                           else ()
        return $path
};

let $base := '/tmp/lctmp'
let $path := '/tmp/lctmp/db'
return local:import($base, $path)
票数 2
EN

Stack Overflow用户

发布于 2014-03-21 13:40:03

除了Ron和Loren建议的方法之外,您还可以使用一个WebDAV客户机--可能是最简单的。或者您可以使用eXide函数编写查询(例如,在xmldb:store-files-from-pattern()中)。在本文将数据输入eXist-db中提到了上述所有内容。

如果您对使用xmldb:store-files-from-pattern()函数感兴趣,以下是具体的说明。您将使用带有$preserve-structure参数的函数的变体。函数的这个变体的函数文档的直接链接是http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/xmldb#store-files-from-pattern.5。以下是一些步骤:

  1. 将.rar文件展开到文件系统上的文件夹中,例如/path/to/ file
  2. 打开eXide (可能在本地系统上的http://localhost:8080/exist/apps/eXide )。以管理员用户的身份登录,以便您的查询能够写入数据库。
  3. 使用此查询: xquery版本"3.0";让$collection-uri := '/db‘let $directory :=’/path/to/file‘let $pattern := '**/*’让$mime类型的:= ()让$ return structure := true()返回$directory $directory,$pattern,$mime类型,$保存-结构)
票数 3
EN

Stack Overflow用户

发布于 2014-03-21 11:27:06

要在eXist中上载文件夹结构,您有两个选项:

  1. 使用Java管理客户端;在普通的eXist安装中,您可以通过浏览器直接访问http://localhost:8080/exist/webstart/exist.jnlp,或者通过http://localhost:8080/exist/apps/dashboard/index.html仪表板上的链接访问它;或者通过快速启动按钮中的弹出菜单访问它(如果在Windows上,则右下角的快速启动工具栏)。在那里,您可以添加整个文件夹。
  2. 将项目打包为XAR存档,它本质上是一个具有适当项目描述符文件的zip归档。见http://exist-db.org/exist/apps/doc/repo.xml的详细信息

希望这能帮上忙

罗恩

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22550974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档