Download TopBraid ComposerPurchase TopBraid ComposerSupportSitemap

SPARQLMotion Example
GeonamesModuleType

This SPARQLMotion script demonstrates how to extend SPARQLMotion with custom module types. Here, we define a specific module that uses an external web service (geonames) to get the geographical coordinates (geo:lat/long) from a place specified by a name. The module type is defined as a subclass of the SPARQLMotion module library class sml:ImportRDFFromURL. The script itself uses the new module type, but any other script can simply import this file and also instantiate this module type. As a result, users no longer need to remember the particular URLs of geonames etc and get a convenient abstraction layer instead.

Download in N3 format (2008-03-11)

Geonames Module Type graph

Details on the steps (in order to execution from top to bottom) follow.

Get place name (type: Bind with parameter) takes external input and binds it to the variable placeName. When used in TopBraid Composer, the user will be prompted to enter a value for this variable. Get place name form
Get place coordinates from Geonames (type: GetLocationFromGeonames as defined below) processes the value of the placeName variable and uses it to retrieve the geo:lat/long values for the given place using the external geonames web service. Get place coordinates form
Display on map (type: Create map) displays all objects that have a geo:lat value on the map. Display on map form

In order to fully understand the script above, we need to understand that the module in the center is an instance of a customized SPARQLMotion module class.

Class tree We have defined a subclass of the class sml:ImportRDFFromURL, called GetLocationFromGeonames. This class inherits the behavior of its parent class, but it pre-defines some of the configuration properties as shown in the form below.

 

The following form displays the class definition of the GetLocationFromGeonames module type.

Custom module type class form

 

The class has an owl:cardinality restriction (placeName exactly 1) on the newly defined property placeName. This property takes string values and must be bound to a value when the module is used. Scripts that use this module type may either pass a bound variable called placeName into the module at run-time, or the script author can set placeName to a static value in the module.

The class also defines an owl:hasValue restriction (in the "has" notation under subClassOf on the form) that sets the URL of the module so that it will be bound to the Geonames service URL. The URL itself is a template containing a place holder for the {?placeName} variable. This will be inserted from the actual run-time value of placeName at execution time.

spacer

spacer

SPARQLMotion