One of the new features in the upcoming TopBraid 3.5 release is called SPINMap. SPINMap is a SPARQL-based language to represent mappings between RDF/OWL ontologies. These mappings can be used to transform instances of source classes into instances of target classes. This is a very common requirement to create Linked Data, for example starting with spreadsheets, XML files or databases, but also from one domain-specific ontology into a more generic one. As a first impression, here is a picture of SPINMap in action:
http://topbraid.org/spin/spinmapl. As a next step, you should drag the source and target ontologies into the Imports view so that those get imported into the mapping ontology. Then select the class you want to start mapping, and switch to the Diagram tab. In the example below, the source ontology A defines a class
a:Person, and we want to map it into the target class
a:Instance-0-1is turned into
b:John-Smith. The dialog provides a collection of target functions that can be used for that purpose. You simply need to pick an appropriate function and fill in the blanks to establish a mapping context. In the example screenshot, a new URI is constructed from the values of the source properties
a:lastNameand a provided URI template. This assumes that those properties together serve as unique identifiers, similar to primary keys in a database. Other algorithms can be created if needed through SPIN functions.
a:dobthat holds date of birth values as raw strings, such as “30/04/1985″. We want to map this into the target property
b:birthDate, which is a well-formed
xsd:datein the format “1985-04-30″. TopBraid's SPARQL library provides a built-in function
spif:parseDateto make this task easier. Use the mouse to draw a connection from
b:birthDate. A dialog such as the following will appear.
spif:parseDatewith pre-defined patterns to convert raw dates into valid
xsd:dateliterals. Pressing OK, this creates a mapping transformation as shown below.
a:Personclass has been mapped into a corresponding instance of
b:Customer. The URI of the target resources has been generated using the string insertion template based on first name and last name. Furthermore, proper birth dates have been generated from the raw source strings. The context menu of the Inferences view provides options to assert the resulting RDF triples if desired, or you can use the Triples View to move them elsewhere.
a:Persondisplays a collection of SPIN Template calls:
spinmap:Mapping-2-1which represents a mapping from 2 source properties into 1 target property. Each of those templates a linked to a
spinmap:Contextwhich is used at execution time to determine the target URIs. Furthermore, the argument
spinmap:expressionpoints to a SPARQL expression, SELECT or ASK query, or even a constant URI or literal that is used to compute the target value from the source value(s). The SPINMap templates are using the function
spin:evalto evaluate those expressions at execution time. When executed, the expression will be invoked with pre-assigned values for
?arg2etc, based on the current values of
spinmap:sourcePredicate1on the source instances.
spinmap:expression, users can also add their own SPIN functions where appropriate. It is also possible to use the built-in SPARQL functions such as
spin:evalto create target URIs. You can open any instance of
spinmap:Contextto see how this is done.
spinmapl:buildURI2is used to derive a new URI from two input properties and a template. You are free to define your own target functions there, as long as they are instances of
spinmap:TargetFunction(and subclass of
spinmap:suggestionXYvalues to the functions. These are SPARQL CONSTRUCT queries that may construct zero or more instances of the function, with partially filled in fields, as well as a
spinmap:suggestionScore. See the function
spif:parseDatefor an example of what can be done with this mechanism.