|
|||||||||||
SPARQLMotion Example
|
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)
Details on the steps (in order to execution from top to bottom) follow.
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.
The following form displays the class definition of the GetLocationFromGeonames module type.
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. |
|