简体   繁体   English

加载多个XML文件(MarkLogic)

[英]Load multiple XML file (MarkLogic)

I need to make search in many files but don't want to write the names of them in the query. 我需要在许多文件中进行搜索,但不想在查询中写入它们的名称。 In my case, I need to query 500 XML files with quite different names each. 就我而言,我需要查询500个名称完全不同的XML文件 So, Is there any way. 所以,有什么办法。

I can say: 我可以说:

for $x in doc("ALL XML files under a specific directory")
return $x/Something

I'm using Ubuntu and MarkLogic5 我正在使用UbuntuMarkLogic5

If your documents are actually in a "directory" ... (ie they are of a form of URL like " /a/b/c.xml ") then you can use xdmp:directory() 如果您的文档实际上在“目录”中(例如,它们是类似“ /a/b/c.xml ”的URL形式),则可以使用xdmp:directory()

http://docs.marklogic.com/xdmp:directory http://docs.marklogic.com/xdmp:目录

for $x in xdmp:directory("/a/b/") 
return $x/something

Mads' answer is correct if by "directory" you mean a Marklogic directory. 如果用“目录”表示Marklogic目录,则Mads的回答是正确的。 If you mean a filesystem path, then the answer is that before Marklogic can process the documents, you need to load them into the database. 如果您指的是文件系统路径,那么答案是在Marklogic处理文档之前,您需要将它们加载到数据库中。

To do this, look at port 8000 on the ML machine (localhost?) and select the "load content" option on that page. 为此,请查看ML计算机上的端口8000(localhost?),然后在该页面上选择“加载内容”选项。 This will allow you to select a filesystem directory to load documents from. 这将允许您选择要从中加载文档的文件系统目录。

By changing "document settings" before loading you can also select how much (if any) of that filesystem path should be maintained as part of the docuemnt URIs in Markloic and assign a collection to all loaded documents. 通过在加载之前更改“文档设置”,您还可以选择应保留多少文件系统路径(如果有的话)作为Markloic中文档URI的一部分,并为所有加载的文档分配一个集合。 I'd encourage you to do both of these; 我鼓励您同时做这两项; they will simplify referring to all of these documents exclusively once they're loaded (either for querying or deletion once you're done with them.) 一旦载入,它们将简化所有这些文档的唯一引用(使用完成后,即可查询或删除)。

Once the documents are loaded, you can query them using xdmp:directory() , fn:collection() or any other method you like. 加载文档后,您可以使用xdmp:directory()fn:collection()或您喜欢的任何其他方法来查询它们。

From Marklogic you can look at the file system if the user has the correct permissions. 如果用户具有正确的权限,则可以从Marklogic查看文件系统。 You could load data into marklogic this way but wouldn't you shouldnt query for data this way. 您可以通过这种方式将数据加载到marklogic中,但是您不应该以这种方式查询数据。

Here is an example and might help you out for what your looking for. 这是一个示例,可能会帮助您找到所需的内容。

 declare namespace dir = "http://marklogic.com/xdmp/directory";

  for $file in xdmp:filesystem-directory("/home/user/desktop/xml/")/dir:entry

  return xdmp:filesystem-file($file/dir:filename) 

For searching files within a particular directory, take a look at cts:directory-query() and the examples in the documentation. 要在特定目录中搜​​索文件,请查看cts:directory-query()和文档中的示例。

http://docs.marklogic.com/cts:directory-query http://docs.marklogic.com/cts:目录查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM