-
-
Notifications
You must be signed in to change notification settings - Fork 8
Template
The structure of the RDF Transform template is stored in a uniform JSON format.
The following example illustrates the template.
{
"baseIRI" : "some://Example/",
"extension" : "RDFTransform",
"namespaces" : {
"foaf" : "http://xmlns.com/foaf/0.1/",
"myp" : "some://Example/namespace/",
"owl" : "http://www.w3.org/2002/07/owl#",
"rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs" : "http://www.w3.org/2000/01/rdf-schema#",
"xsd" : "http://www.w3.org/2001/XMLSchema#",
"vcard" : "http://www.w3.org/2006/vcard/ns#"
},
"subjectMappings" : [
{
"expression" : {
"code" : "toIRIString(row.record.index)",
"language" : "grel"
},
"prefix" : "myp",
"propertyMappings" : [
{
"objectMappings" : [
{
"expression" : {
"code" : "toIRIString(toStrippedLiteral(value))",
"language" : "grel"
},
"prefix" : "myp",
"valueSource" : {
"columnName" : "name/family",
"source" : "column"
},
"valueType" : {
"type" : "iri"
}
}
],
"prefix" : "myp",
"valueSource" : {
"constant" : "familyName",
"source" : "constant"
}
},
{
"objectMappings" : [
{
"valueSource" : {
"columnName" : "timestamp",
"source" : "column"
},
"valueType" : {
"datatype" : {
"prefix" : "xsd",
"valueSource" : {
"constant" : "dateTime",
"source" : "constant"
}
},
"type" : "datatype_literal"
}
}
],
"prefix" : "myp",
"valueSource" : {
"constant" : "collectedOn",
"source" : "constant"
}
},
{
"objectMappings" : [
{
"valueSource" : {
"columnName" : "notes/comments",
"source" : "column"
},
"valueType" : {
"language" : "en",
"type" : "language_literal"
}
}
],
"prefix" : "mpy",
"valueSource" : {
"constant" : "notes",
"source" : "constant"
}
}
],
"typeMappings" : [
{
"prefix" : "myp",
"valueSource" : {
"constant" : "Classy",
"source" : "constant"
}
}
],
"valueSource" : {
"source" : "record_id"
}
}
],
"version" : "2.0.0"
}
The RDF Tranform can be exported as a JSON template. The JSON structure is use internally to manage the RDF Transform elements. The JSON structure is shown below. This structure is further dissected and discussed.
{
"baseIRI" : "some://Example/iri",
"extension" : "RDFTransform",
"namespaces" : {
"(prefix)" : "some://Example/namespace",
...
},
"subjectMappings" : [
{
"expression" : {
"code" : "(some expression code)",
"language" : "grel"
},
"prefix" : "(prefix)",
"propertyMappings" : [
{
"objectMappings" : [
{
"expression" : {
"code" : "(some expression code)",
"language" : "grel"
},
"prefix" : "(prefix)",
"valueSource" : {
"columnName" : "(some column name)",
"source" : "column"
},
"valueType" : {
"type" : "iri"
}
},
...
],
"prefix" : "(prefix)",
"valueSource" : {
"constant" : "(some constant)",
"source" : "constant"
}
},
{
"objectMappings" : [
{
"valueSource" : {
"columnName" : "(some column name)",
"source" : "column"
},
"valueType" : {
"datatype" : {
"prefix" : "(prefix)",
"valueSource" : {
"constant" : "(some constant)",
"source" : "constant"
}
},
"type" : "datatype_literal"
}
},
...
],
"prefix" : "(prefix)",
"valueSource" : {
"constant" : "(some constant)",
"source" : "constant"
}
},
{
"objectMappings" : [
{
"valueSource" : {
"columnName" : "(some column name)",
"source" : "column"
},
"valueType" : {
"language" : "(some language value)",
"type" : "language_literal"
}
},
...
],
"prefix" : "(prefix)",
"valueSource" : {
"constant" : "(some constant)",
"source" : "constant"
}
},
...
],
"typeMappings" : [
{
"prefix" : "(prefix)",
"valueSource" : {
"constant" : "(some constant)",
"source" : "constant"
}
}
],
"valueSource" : {
"source" : "(some source)"
}
},
...
],
"version" : "(some version id)"
}
The Header section consists of the following:
{
"baseIRI" : "some://Example/iri",
"extension" : "RDFTransform",
"namespaces" : {
"(prefix)" : "some://Example/namespace/",
...
},
...
"version" : "(some version id)"
}
The various Header elements are:
- The "baseIRI" key describes the default namespace when a prefix is not given.
- The "extension" key identifies the RDF Transform extension as the generating origin.
- The "namespace" key describes a container of key:values pairs for the embedded namespaces where the key is the short prefix identifier and the value is the related IRI namespace.
- The "version" key is the extension version used to generate the JSON.
The template is a mapping used to process triples from the data and contains elements that match up to the triple components: subject, property, and object. The initial subjects are found in the Triple Mapping section designated by the "subjectMappings" key. The "subjectMappings" key holds a list of subject maps. The properties are found in each subject map designated by the "propertyMappings" key. The "propertyMappings" key holds a list of property maps. The objects are found in each property map designated by the "objectMappings" key. The "objectMappings" key holds a list of object maps. An object map may, in turn, be a subject for another triple holding its own "propertyMappings" key and so on.
The Triple Mapping section consists of the following:
"subjectMappings" : [
{
...
"propertyMappings" : [
{
...
"objectMappings" : [
{
...
},
...
],
...
},
...
],
...
},
...
],
The "subjectMappings" key describes a list of Root Node subject (resource) maps that start a triple expression. The "propertyMappings" key describes a list of property (resource) maps. The "objectMappings" key describes a list of object (resource or literal) maps.
NOTE: An incomplete Triple Mapping section may exist with only partially complete triple maps as the JSON represents the work in the Transform Tab which may be a work-in-progress.
The subject and object maps have a similar structure for resource and literal mapping:
...
{
"expression" : {
"code" : "(some expression code)",
"language" : "grel"
},
"prefix" : "(some prefix value)",
"propertyMappings" : [
...
],
"typeMappings" : [
...
],
"valueSource" : {
...
},
"valueType" : {
...
}
}.
...
The various resource and literal mapping elements are:
- [OPTIONAL] The "expression" key describes the expression container. Expressions are used to calculate some result that can be used as a resource or literal. The expression container holds a "code" key that has the coding language statements as its value. It also holds a "language" key that has the coding language value. Currently, GREL ("grel") is the only coding language recognized. Resources and literals have a default expression as the source "value" (see "valueSource" below).
- [OPTIONAL] The "prefix" key identifies the prefixed namespace used for an IRI and is appended to the Local Part of the IRI to form a Condensed IRI Expression (CIRIE). Resources may have prefixes. Literals do not have prefixes.
- The "propertyMappings" key describes the list of property maps as discussed previously.
- [OPTIONAL] The "typeMappings" key describes a specialized list of type maps. Type maps always use an "rdf:type" (or "a") property with the given type information as the object to produce "type" triples for a resource. The "typeMappings" key is discussed in more detail later.
- The "valueSource" key describes the node's source information for a resource or literal and is discussed in more detail later.
-
[OPTIONAL] The "valueType" key describes the node's type information for a resource or literal and is discussed in more detail later.
For Root Node subject maps, the "valueType" key section is optional as all Root Nodes subjects are always resource IRIs and, therefore, have a default "iri" type value. Root Nodes subject maps may also be specified as Blank Nodes. For object maps, objects may be either resources or literals. Then, the "valueType" key section is used to designate resource or literal type values.
The property maps have a reduced structure for resource mapping:
...
{
"objectMappings" : [
...
]
"prefix" : "(prefix)",
"valueSource" : {
...
},
}.
...
Since all properties are resource IRIs, the "valueType" key is not needed. Additionally, the "valueSource" key currently always specifies a constant resource. Then, the "expression" key is also not needed.
NOTE: As properties are not normally typed, the "typeMappings" key is not needed. To type a property, create a new Root Node designed to be equal to the property IRI and use the "Add type..." feature or designate a "rdf:type" property map and an object map to use as the type.
The various property mapping elements are:
- The "objectMappings" key describes the list of object maps as discussed previously.
- [OPTIONAL] The "prefix" key identifies the prefixed namespace used for an IRI as discussed previously. It is harvested from the source information if present.
- The "valueSource" key describes the property's source information for a resource. It currently always specifies a constant resource and is discussed in more detail later.
The type maps have a reduced structure for resource mapping:
...
{
"prefix" : "(prefix)",
"valueSource" : {
"constant" : "(IRI Local Part)",
"source" : "constant"
}
},
{
"valueSource" : {
"constant" : "(Full IRI)",
"source" : "constant"
}
},
...
A type map currently always specifies a constant resource. The constant resource may be a prefixed IRI (a CIRIE) or a fully specified IRI. If prefixed, the prefix is harvested from the constant and mapped in the JSON structure. If there is no suitable prefix, the "prefix" key is not used and the constant remains as entered.
The various type mapping elements are:
- [OPTIONAL] The "prefix" key identifies the prefixed namespace used for an IRI as discussed previously. It is harvested from the source information if present.
- The "valueSource" key describes the type's source information for a resource. It currently always specifies a constant resource and is discussed in more detail later.
The "valueSource" key container consists of the following:
...
"valueSource" : {
"source" : "(source type)",
"(source key)" : "(source value)"
},
...
The "valueSource" key container elements are:
- The "source" key identifies some (source type). The (source type) corresponds to the (source key). The (source type) may be:
- row_index - a row index type, use the row index for the value. The (source key) is unused.
- record_id - a record index type, use the record index for the value. The (source key) is unused.
- column - a data column type, use a data column name cell for the value. The (source key) is specified as "columnName".
- constant - a constant type, use the user enter constant value for the value. The (source key) is specified as "constant".
- expression - (UNUSED) an expression type, use the value derived from the user enter expression. The (source key) is specified as "expression".
-
[DEPENDENT] The "(source key)" key identifies the (source value) used for the source. The (source key) may be:
- columnName - the (source value) is a data column name use to retrieve cell values.
- constant - the (source value) is a user entered constant used as the value. Constant values result in a singleton value used throughout the transform.
- expression - (UNUSED) the (source value) is an expression to evaluate as the value. The resulting value may be constant or variable.
The "valueType" key container consists of the following:
...
"valueType" : {
"type" : "(value type)",
"(type key)" : (type structure)
},
...
The "valueType" key container elements are:
- The "type" key identifies some (value type). The (value type) corresponds to the (type key). The (value type) may be:
- iri - an IRI is generated from the source value. The (type key) is unused.
- bnode - a variable Blank Node resource is generated from the source value. The source values is derived from either an row / record index or a column name. Index based Blank Nodes generate a unique random ID per index. Column based Blank Nodes generate a unique ID from the column name + the row index. The (type key) is unused.
- value_bnode - a constant Blank Node resource is generated from the constant value. The constant Blank Node is a singleton node used throughout the transform. The (type key) is unused.
- literal - a generic literal is generated from the source value. The (type key) is unused.
- language_literal - a language tagged literal is generated from the source value. The (type key) is specified as "language".
- datatype_literal - a datatyped literal is generated from the source value. The (type key) is specified as "datatype".
-
[DEPENDENT] The "(type key)" key identifies the (type structure) used for the type. The (type key) may be:
- language - the (type structure) is a simple string consisting of an ISO 639-1 two character language code that identifies the language of the literal. Examples: "en", "es", "ja", "it", "de", etc.
- datatype - the (type structure) is a type map structure for resource mapping as previously dicsussed (see "type maps" above).