Inspecting the Repository
A convenient way to query and inspect the repository is through an interactive shell. In Java 6 for Windows, Linux,
and Solaris, there exists a tool called
jrunscript, which is a JavaScript interactive shell. If you are not using
Java 6 on one of these platforms, you can download
Mozilla's Rhino interactive JavaScript shell or use an interactive
shell for another language, such as
Groovy
or
JRuby. However, the syntax varies between shells.
Be sure to set the CLASSPATH environment variable correctly to include all the jars from the application.
Now start the interactive shell using the command:
jrunscript
Just like when writing Java code, you need to import the packages you plan on using. This is done using the following
commands:
- importPackage(java.io)
- importPackage(java.util)
- importPackage(javax.xml.namespace)
- importPackage(org.openrdf.elmo)
- importPackage(org.openrdf.elmo.sesame)
- importPackage(org.openrdf.rio)
- importPackage(org.openrdf.rio.rdfxml)
You can also execute these in the command line by using the '-e' argument followed by the command and then '-f -' to jrunscript.
Run the following commands to open a connection to the repository:
js> factory = new SesameManagerFactory(new ElmoModule(),“devx”,“rdf”))
js> manager = factory.createElmoManager()
OpenRDF Elmo uses the newly standardized SPARQL query language.
To execute a query, run the commands from Listing 3.
Although this shell is useful for arbitrary inspection, it is difficult to get the bigger picture.
However, you can also export the data into RDF/XML (a portable format). With the repository exported you can browse
the contents more interactively in your browser.
js> manager.connection['export'](new RDFXMLWriter(new FileWriter("export.rdf")))