IPSM-AF Cell formats
IPSM-AF allows
to persist translation logic in alignment cells. In each cell source RDF graph pattern (element entity1
) and target RDF graph pattern (element entity2
)
are specified. Additionally, more complex transformations with function calls can be included in the translation (element transformation
).
The content of entity1
and entity2
can be persisted using different RDF syntaxes. At the moment RDF/XML (default) and Turtle are supported.
To specify which syntax will be used, in alignment header put:
<sripas:cellFormat>
<iiot:DataFormat rdf:about="http://inter-iot.eu/sripas#turtle" />
</sripas:cellFormat>
or optionally
<sripas:cellFormat>
<iiot:DataFormat rdf:about="http://inter-iot.eu/sripas#rdfxml" />
</sripas:cellFormat>
RDF/XML
This is a default syntax, in which a cell is encoded as XML and looks like:
<align:Cell rdf:about="http://www.inter-iot.eu/sripas#cell_id">
<align:entity1 rdf:parseType="Literal">
...
</align:entity1>
<align:entity2 rdf:parseType="Literal">
...
</align:entity2>
<align:relation>=</align:relation>
...
</align:Cell>
Here, is the example of a cell for translation of geographic coordinates from geoSPARQL to Basic Geo Vocabulary format. The sample source structure is (prefixes are expanded as described here):
{
"@id" : "ont1:instance1",
"@type" : ["http://www.opengis.net/ont/geosparql#Geometry" ],
"http://www.opengis.net/ont/geosparql#asWKT" : {
"@type" : "http://www.opengis.net/def/sf/wktLiteral",
"@value" : "Point(52.3 98.2)"
}
}
and the target:
{
"@id" : "p1ont:PositionMeasurementValue",
"@type" : "geo:Point",
"geo:lat": {
"@type" : "http://www.w3.org/2001/XMLSchema#float",
"@value" : "52.3"
},
"geo:long": {
"@type" : "http://www.w3.org/2001/XMLSchema#float",
"@value" : "98.2"
}
}
<align:Cell rdf:about="http://www.inter-iot.eu/sripas#cell_id">
<align:entity1 rdf:parseType="Literal">
<var:CTX>
<rdf:type rdf:resource="http://www.opengis.net/ont/geosparql#Geometry"/>
<geosparql:asWKT>
<var:x/>
</geosparql:asWKT>
</var:CTX>
</align:entity1>
<align:entity2 rdf:parseType="Literal">
<var:CTX>
<rdf:type rdf:resource="http://www.w3.org/2003/01/geo/wgs84_pos#Point"/>
<geo:lat>
<var:lat />
</geo:lat>
<geo:long>
<var:long />
</geo:long>
</var:CTX>
</align:entity2>
<align:relation>=</align:relation>
<align:measure rdf:datatype ="http://www.w3.org/2001/XMLSchema#float">1.0</align:measure>
<sripas:transformation rdf:parseType="Literal">
<sripas:function sripas:about="str">
<sripas:param sripas:order="1" sripas:about="&var;x"/>
<sripas:return sripas:about="&var;sx"/>
</sripas:function>
<sripas:function sripas:about="replace">
<sripas:param sripas:order="1" sripas:about="&var;sx"/>
<sripas:param sripas:order="2" sripas:val="^Point\\((\\d+\\.\\d+)\\s+\\d+\\.\\d+\\)$"/>
<sripas:param sripas:order="3" sripas:val="$1"/>
<sripas:param sripas:order="4" sripas:val="i"/>
<sripas:return sripas:about="&var;lat"/>
</sripas:function>
<sripas:function sripas:about="replace">
<sripas:param sripas:order="1" sripas:about="&var;sx"/>
<sripas:param sripas:order="2" sripas:val="^Point\\(\\d+\\.\\d+\\s+(\\d+\\.\\d+)\\)$"/>
<sripas:param sripas:order="3" sripas:val="$1"/>
<sripas:return sripas:about="&var;long"/>
</sripas:function>
</sripas:transformation>
<sripas:filters rdf:parseType="Literal">
<filter about="&var;x" datatype="http://www.opengis.net/def/sf/wktLiteral"/>
</sripas:filters>
<sripas:typings rdf:parseType="Literal">
<sripas:typing sripas:about="&var;lat" sripas:datatype="http://www.w3.org/2001/XMLSchema#float"/>
<sripas:typing sripas:about="&var;long" sripas:datatype="http://www.w3.org/2001/XMLSchema#float"/>
</sripas:typings>
</align:Cell>
Turtle
In this case the cell looks like:
<align:Cell rdf:about="http://www.inter-iot.eu/sripas#cell_id">
<align:entity1 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
...
</align:entity1>
<align:entity2 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
...
</align:entity2>
<align:relation>=</align:relation>
...
</align:Cell>
The use of variables follows the same rules in both syntaxes. Prefixes used in alignment cells should be declared globally in rdf:RDF
element.
The aforementioned cell example in RDF/XML can be expressed as follows in Turtle:
<align:Cell rdf:about="http://www.inter-iot.eu/sripas#cell_id">
<align:entity1 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
var:CTX a geosparql:Geometry ;
geosparql:asWKT var:x .
</align:entity1>
<align:entity2 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
var:CTX a geo:Point ;
geo:lat var:lat ;
geo:long var:log .
</align:entity2>
<sripas:transformation rdf:parseType="Literal">
<sripas:function sripas:about="str">
<sripas:param sripas:order="1" sripas:about="&var;x"/>
<sripas:return sripas:about="&var;sx"/>
</sripas:function>
<sripas:function sripas:about="replace">
<sripas:param sripas:order="1" sripas:about="&var;sx"/>
<sripas:param sripas:order="2" sripas:val="^Point\\((\\d+\\.\\d+)\\s+\\d+\\.\\d+\\)$"/>
<sripas:param sripas:order="3" sripas:val="$1"/>
<sripas:param sripas:order="4" sripas:val="i"/>
<sripas:return sripas:about="&var;lat"/>
</sripas:function>
<sripas:function sripas:about="replace">
<sripas:param sripas:order="1" sripas:about="&var;sx"/>
<sripas:param sripas:order="2" sripas:val="^Point\\(\\d+\\.\\d+\\s+(\\d+\\.\\d+)\\)$"/>
<sripas:param sripas:order="3" sripas:val="$1"/>
<sripas:return sripas:about="&var;long"/>
</sripas:function>
</sripas:transformation>
<sripas:filters rdf:parseType="Literal">
<filter about="&var;x" datatype="http://www.opengis.net/def/sf/wktLiteral"/>
</sripas:filters>
<sripas:typings rdf:parseType="Literal">
<sripas:typing sripas:about="&var;lat" sripas:datatype="http://www.w3.org/2001/XMLSchema#float"/>
<sripas:typing sripas:about="&var;long" sripas:datatype="http://www.w3.org/2001/XMLSchema#float"/>
</sripas:typings>
</align:Cell>