Database Reference
In-Depth Information
documents use the same credentials. Typically, you will work with a single Data
base instance. See Example 13-21 .
Example 13-21. Starting an eXist embedded instance with the Fluent API
Database . startup ( new File ( "conf.xml" ));
Database db = Database . login ( "admin" , "" );
Folder s
A Folder in the Fluent API maps onto a collection in the eXist database. Folders
are the primary means for interacting with the Fluent API. From a folder you
may manage subfolders and documents. See Example 13-22 .
Example 13-22. Getting a Folder reference from the Fluent API
Folder folder = db . getFolder ( "/db" );
Document s
A Document in the Fluent API maps onto a document in the eXist database. The
Fluent API allows you to work with both eXist's XML and binary documents.
Binary documents will be of type org.exist.fluent.Document , and XML docu‐
ments are of a subtype of that, org.exist.fluent.XMLDocument . See
Example 13-23 .
Example 13-23. Retrieving a Document from the Fluent API
Document doc = folder . documents (). get ( "some-document.xml" );
QueryService s
A QueryService in the Fluent API allows you to execute XQueries against fold‐
ers or documents in the database. A QueryService may be retrieved from a data‐
base, a folder, or a document object (if you want finer-grained control over the
query context). The result of executing a query with the QueryService is an
instance of org.exist.fluent.ItemList , which you may iterate over to obtain
individual org.exist.fluent.Item instances, from which you may then retrieve
a result value. See Example 13-24 .
Example 13-24. Querying a folder with the Fluent API
ItemList results = folder . query . all ( "//my-node" );
for ( Item result : results ) {
System . out . println ( result . value );
}
Search WWH ::




Custom Search