问题
I am wondering how one creates a collection and adds a document to that collection in a fresh zorba install using the commandline interface http://www.zorba-xquery.com/html/documentation/2.7.0/zorba/commandline
If it cannot be done with the command line an example using the scripting api would be good.
回答1:
This can be done using XQuery scripting. Consider the following XQuery module:
module namespace news-data = "http://www.news.org/data";
declare namespace an = "http://www.zorba-xquery.com/annotations";
declare collection news-data:employees as element(employee)*;
declare variable $news-data:employees := xs:QName('news-data:employees');
You can use it like this:
import module namespace news-data = "http://www.news.org/data" at "news-data.xq";
import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
ddl:create($news-data:employees);
dml:insert-nodes($news-data:employees, doc("test2.xml"));
来源:https://stackoverflow.com/questions/13026559/create-collection-add-document-to-zorba-using-command-line