Free Open-Source Software

Using the XBRLAPI from the command line


This page is relevant to those looking to perform some basic command line tests that XBRLAPI is available from their commandline.

Get Java on the command line

Type java -version at the command line to see if Java is available. You should see a message indicating that the java version is 1.6 or later. See the Java configuration page if you run into troubles.

Get the necessary JAR files

Ensure that the XBRLAPI JAR files are on the class path. This can be done by placing them in the lib/ext directory in the Java installation. It can also be done by modifying the CLASS_PATH environment variable to include the directory that contains the XBRLAPI JAR files. It can also be done by ensuring that the current directory for the command line operations also contains the XBRLAPI JAR files.

At a minimum you will need:

where VERSION is the XBRLAPI release VERSION.

Alternatively you can just get the xbrlapi-VERSION.jar file and use it. It contains all the other modules in a single JAR for convenience.

Download the necessary XBRLAPI modules as JAR files from Sourceforge. You will definitely require the xbrlapi-utilities module, the xbrlapi-api module, the xbrlapi-xlink, xbrlapi-xpointer and xbrlapi-xmlbase modules. If you want to use a persistent data store, then you will also require one of the xbrlapi-bdb-xml or xbrlapi-exist modules.

You can also download the latest snapshot of the API from the SVN repository. This is generally not broken (in the sense that that unit tests pass) but neither will it be stable.

You will also need a number of third party JAR files.

To make things easy, these have been included in the SVN repository for the XBRLAPI so if you check out the XBRLAPI project from SVN then you should have them all. Alternatively you can download those that you require directly from the browseable SVN repository.

Look in the Maven POM files to determine which third party JARs you need.

Put the JAR files on your CLASS_PATH

Make sure that all of the necessary JAR files (the XBRLAPI ones and the third party dependency ones) are on your Java CLASS_PATH. If you have installed a complete Java SDK, then a very simple way to achieve this outcome is to place them in your $JAVA_HOME/jre/lib/ext directory where $JAVA_HOME is the value of the JAVA_HOME environment variable set when you installed your Java SDK. If you are identifying the necessary JAR files using the -classpath parameter, then be sure not to also use the -jar parameter for the Java runtime engine.

Configure log4j

You need to configure log4j. This configuration is specified in an XML file. A useful starting point for such a log4j configuration is available from the online SVN browsing facility at Sourceforge. Download the log4j.xml file and its DTD (or if you have checked out the entire XBRLAPI project, then just use the log4.xml file that is in the conf directory of the XBRLAPI project) and store it somewhere convenient, say /configuration/file/path/log4j.xml. This configuration file is set up to send log messages to the console.

Configure your local cache for XBRL documents

The XBRLAPI caches any documents that are loaded into a data store. You need to set up a writeable folder to store this cache. When populated, the cache will contain a local copy of each of the XML documents that are discovered during the loading process. Refer to the directory where the local copies are to be cached as: /xbrl/cache/

At this point you have just about enough basic configuration to run your own programs using the XBRLAPI from the commandline. There are a few specific commandline programs with more detailed documentation in the examples on this website.

Running the Unit tests distributed with XBRLAPI

A more comprehensive test of your XBRLAPI installation is possible using the TestNG tests that are distributed with XBRLAPI.

Get Java XBRL API implementation at Fast, secure and Free Open Source software downloads