In BaseX you can create databases with single XML files or databases with a bunch of XML files, called collections. The creation, management and access of these collections is described in the follwing sections.
Creation of a collection
You can create a collection either within the GUI or in the console version of BaseX.
- GUI: choose File » New » Browse » choose directory and press OK
- Console: enter
basex -c "create db dbname /path/to/collection"
Additionaly to the creation with your choosen xml files you can start with creating an empty
collection and then add your xml files to it. Note that the
commands just operate on an opened database.
- Create an empty database:
create db example
- <a href="commands#add">Add</a> a document:
- <a href="commands#delete">Delete</a> a document:
For more information see our <a href="tutcolls">tutorial</a>.
Access documents in collections
collection() function can be used to access documents in collections:
- Returning all documents of collection ("dbname"):
for $doc in collection("dbname") return base-uri($doc)
- Access a specific document ("test") in collection ("dbname"):