Main Page » Developer Section » Java Examples

Java Examples

The following Java code snippets demonstrate how easy it is to run database commands, create collections, perform queries, etc. by integrating the BaseX code. Most examples are taken from our basex-examples repository, in which you will find some more use cases.

Local Examples

The following code snippets work in embedded mode; they do not rely on an additional server instance:

Server Examples

The examples below take advantage of the client/server architecture:

XQuery Module Examples

BaseX provides Java Bindings for accessing external Java code via XQuery functions. The following examples show how this feature can be utilized:

  • FruitsExample.java demonstrates how Java classes can be imported as XQuery modules.
  • FruitsModule.java is a simple demo module called by FruitsExample.
  • ModuleDemo.java is a simple XQuery demo module that demonstrates how XQuery items can be processed from Java. It is derived from the QueryModule class.
  • QueryModule.java is located in the BaseX core. Java query modules can extend this class to get access to the current query context and enrich functions with properties.

Client API

REST API

XML:DB API (deprecated)

Note that the XML:DB API does not talk to the server and can thus only be used in embedded mode.

XQJ API (closed source)

The implementation of the BaseX XQJ API has been written by Charles Foster. The basex-examples repository contains various examples on how to use XQJ.


⚡Generated with XQuery