Changes

Jump to navigation Jump to search
64 bytes removed ,  17:19, 13 October 2011
no edit summary
==IntroductionCreate Databases==In BaseX, there are two kinds of databases. It is possible to havedatabases with single XML documents and databases with a bunch of XML files, called ''Collections''.
===Creation of In BaseX, a single database===can contain one or more XML documents, called ''Collection'', and raw (binary) files.You New databases can create a database either be created within the GUI or in the console version of BaseX. :
*[[Startup#BaseX GUI|GUI]]: Go to ''Database'' → ''New'' and then , press ''Browse '' to choose a file or directory, and press ''OK ''*[[Startup#BaseX Standalone|Console]]: enter <code>basex -c "CREATE DB dbname /path/to/fileresources"</code><br/>
==CollectionManage Collections==
===Creation of Once you have created a collection===database, additional commands exist to modify its contents:You * XML documents can create a collection either within be added with the GUI or in the console version of BaseX<code>[[Commands#ADD|ADD]]</code> command. *GUI: Go to ''Database'' → ''New'' and then press Browse to choose a directory and press OK Raw files are added with <code>[[Commands#STORE|STORE]]</code>.*Console: enter Resources can be replaced with others using the <code>basex -c "CREATE DB dbname [[Commands#REPLACE|REPLACE]]</path/to/collection"code> command.* Resources can be deleted with the </code>[[Commands#DELETE|DELETE]]<br/code>command.
===Manage Collections=== Additional to the creation with your choosen xml files you can start with creating The following commands create an emptycollection and then database, add your xml files to it. Note that the <code>[[Commands#ADD|ADD]]</code>two resources and <code>[[Commands#DELETE|DELETE]]</code> commands refer to the currently opened database.  Consolefinally delete them again:* Create an empty database: <codepre>CREATE DB example</code> * Add a document: <code>ADD example.xml<ADD TO images/code> 123.jpg* Delete a document: <code>DELETE example.xml/</codepre>  GUI:In the GUI you can execute all above operations in the Database menu.
Once you have created a database, you You may as well use the BaseX-specific [[Database Functions|XQuery Database Functions]] to add or , replace and delete XML documents:
<pre class="brush:xquery">
</pre>
=Last but not least, XML documents can also be added via the GUI and the ''Database'' menu. ==Access documents in collections=Documents==The Various XQuery <code>collection()</code> function can be used functions exist to access the XML documents in collectionsdatabases and other locations: *Returning all documents of collection <code>db:open("dbname", "/path/to/docs")</code>:returns documents that are found in the specified database<br/code> * <code>for $doc in collection("dbnamepath/to/docs") return base-uri($doc)</code> *Access a specific document ("test") : returns the documents that are either found in collection ("dbname"):the specified database or file path<br/code> * <code>collectiondoc("dbnamepath/to/testdocument.xml")<//*code>: returns a single document found at the specified location. If a database exists for the specified file, it is opened instead.</code>
[[Category:Beginner]]
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu