Hi Jan, hi all,
I forgot to post my last (and short) answer to Edward to the list.. We have created a small entry in our Wiki that is supposed to answer questions around databases in BaseX:
http://docs.basex.org/wiki/Databases
In BaseX, a single database contains an arbitrary number of resources, addressed by their unique database path. Resources can either be XML documents or raw files (binaries). As sets of XML documents are also called collections, a BaseX database may either contain a single collection. When new collections are added to the database, they will be represented in the same directory hierarchy.
We have recently added new functions to simplify the access to resources within databases:
-- The db:open() function returns documents that are found in a database -- fn:collection() either returns documents of a database or of the specified location -- fn:doc() returns a single document, or opens a database for this specific document. In the latter case, the database may only contain the one addressed document.
I hope this answers some more questions; you are welcome to ask for more (..or edit the Wiki entry in question if you feel that it's incomplee ;).
Christian ___________________________
On Tue, Nov 8, 2011 at 10:21 AM, Jan Vlčinský (CAD) jan.vlcinsky@cad-programs.com wrote:
What a great question and answer. Additional question: what is relation between the only document in the database, and collection of documents, stored in that database. Is it like this?: database contains one document, this document is/defines collection of documents. Am I correct? Jan Vlčinský
On 8 November 2011 10:07, Michael Seiferle michael.seiferle@uni-konstanz.de wrote:
Hi Edward, thanks for you email. Am 08.11.2011 um 05:40 schrieb Edward Fong:
Hi, What's the diff between Database and collection? I think there are same in baseX, am I right?
close, a database contains one document node, while a collection is allowed to contain several document nodes. You can easily create a collection by creating a database from a source directory, by running the following command. CREATE db collection-test /path/to/xml-directory To query individual file inside that collection you can use the following: for $doc in collection('test/input.xml') return base-uri($doc) To query each file inside your collection run the following: for $doc in collection('test') return base-uri($doc)
Where 'test' is the name of the collection and '/input.xml' is the path to the document inside this collection. I hope this helps, feel free to ask for more information as needed. Kind regards Michael
And how to query by a document name? Following are steps of my testing: 1: loaded some xml files form a directory: d:\data\org-*.xml 2: query by doc('org-100525.xml') and got File or directory "D:/Program Files (x86)/BaseX701/bin/org-100525.xml" not found message. 3: because after loaded xml, directory: d:\data\org-*.xml was removed. I can't query by doc('d:\data\org-100525.xml')
Thanks, Edward
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk