Tuesday, May 19, 2009

Interacting with XML-based web services using SPARQLMotion

One of the new features of TopBraid 3.0 is improved handling of web services that return XML results. We have added two new module types to SPARQLMotion that can be used to walk through XML documents via XPath. Here is an illustrated example of how to use these capabilities. You can also download and play with the example script.

The first step is a web service call using sml:ImportXMLFromWorkspace:

In this example we are using a fixed URL from the geonames.org web service:

We can run this trivial script with the debug button to examine the XML result in TopBraid's console:

Our query takes a postal code as input and delivers an XML structure of matching Australian suburbs. We want to copy some of the result values into our simple Suburbs ontology, and capture name, latitude and longitude of each suburb.

In order to do that, we want to walk through all code tags of the XML result. We add an sml:IterateOverXPath module that takes the ?xml from the previous step as input:

At this stage, Composer offers a convenience feature: right click on the IterateOverXPath module and select "Set XPath...": this will execute the script up to that module and open up an XPath creation dialog. This dialog can be used to select the path to the elements that we want to iterate over:
After we have defined and assigned the XPath, we can now specify what we want to do with each code element from the XML document. In order to do so, we create the body of the iteration module as shown in the overview below. This body will be repeated for each code element. The ?xml variable is then bound to the current code element as root.

Each of the three sml:BindByXPath modules has a local XPath starting at the respective code element. Again, we can use the "Set XPath..." feature to let the SPARQLMotion engine execute up to the module and open an XPath editor dialog:
We simply need to pick the example instance data (here, the specific latitude value) and the dialog will generalize it into an XPath expression in the text field. This will bind the specified text node to the variables ?name, ?lat and ?long. In the final step, we define a SPARQL Construct query using sml:ApplyConstruct to create RDF triples for those values:

The complete script can now be executed, and SPARQLMotion we can infer the resulting triples so that we can browse them in TopBraid:
The result is that we have converted the XML data from the web service call into instances of the my:Suburb class in our ontology:

SPARQLMotion is of course more general than that, and you can combine such web service calls with any other type of processing supported by the engine. You can also use the same technique to interact with other XML documents such as local files.

Friday, May 01, 2009

TopBraid Suite 3.0 is here!

Roughly nine months after our previous official TopBraid Composer release, we have today released TopBraid Suite 3.0! This is not just another Composer version, but a significant milestone for TopQuadrant's product offerings. For the first time, we have integrated and aligned the releases of Composer with an all-new TopBraid Live and TopBraid Ensemble.

Ensemble has been redesigned completely and makes the development of Semantic Web applications easier than ever - completely without programming in the traditional sense. The best way to experience these new capabilities is to start TBC Maestro and then open a web browser at http://localhost:8083/tbl. This will open up the TopBraid Live welcome screen from which you can open an Ensemble application on whatever ontology you have in your Composer workspace, such as the following:

By default, Ensemble is a generic linked data browser and editor with features such as trees, graphs, tables, charts, search and maps. There are two main innovations of Ensemble that make it different from similar frameworks though:
  • Customizing an application is easy: for example, if you want to change the kind of hierarchy to display in the tree, just configure it in TBE and save your application so that others can use it too. We have a purely model-driven architecture that represents the state of each application in RDF.
  • Adding new functionality is easy: you can define SPARQLMotion scripts on the server and make them accessible via buttons in TBE. For example, you can define new operations that manipulate the currently selected tree node in whatever way you like, or you can import new data from RSS feeds or whatever else SPARQLMotion allows you to do. And if that's not enough, you can of course extend SPARQLMotion on the server.
There are several other major innovations in TopBraid 3.0, including SPIN which I have written about in many previous blog entries. We hope you enjoy the new TopBraid!