diff --git a/spec/docs/advanced.md b/spec/docs/advanced.md index 6ab323b..283c07b 100644 --- a/spec/docs/advanced.md +++ b/spec/docs/advanced.md @@ -13,7 +13,10 @@ For an old example, see [RMLFNOTC0018](https://github.com/RMLio/rml-fno-test-cas For now, it is unclear how to handle a nested function where that nested Triples Map contains a join condition.

-```turtle "example": "use nested function" + + +### Conditions + +Conditions are a shortcut to make RML mappings more intuitive, but rely on existing FNML functionality. +It is a shortcut that is applied using the `rml:condition`: an additional ExpressionMap predicate. +To be able to use this shortcut, conforming mapping engines MUST support following functions: + +- isNull +- isNotNull +- equals +- noEquals +- IF + +

+ isNotNull and IF are defined below, rest is an excercise for the reader. + The actual FnO definitions are TODO. +

+ + diff --git a/spec/docs/config.js b/spec/docs/config.js new file mode 100644 index 0000000..85f5c35 --- /dev/null +++ b/spec/docs/config.js @@ -0,0 +1,105 @@ +async function loadTurtle() { + //this is the function you call in 'preProcess', to load the highlighter + const worker = await new Promise(resolve => { + require(["core/worker"], ({ worker }) => resolve(worker)); + }); + const action = "highlight-load-lang"; + const langURL = + "https://cdn.jsdelivr.net/gh/redmer/highlightjs-turtle/src/languages/turtle.js"; + const propName = "hljsDefineTurtle"; // This funtion is defined in the highlighter being loaded + const lang = "turtle"; // this is the class you use to identify the language + worker.postMessage({ action, langURL, propName, lang }); + return new Promise(resolve => { + worker.addEventListener("message", function listener({ data }) { + const { action: responseAction, lang: responseLang } = data; + if (responseAction === action && responseLang === lang) { + worker.removeEventListener("message", listener); + resolve(); + } + }); + }); +} + +var respecConfig = { + // check https://respec.org/docs/ for the meaning of these keys + preProcess: [loadTurtle], + authors: [ + { + name: "Ben De Meester", + }, + { + name: "Samaneh Jozashoori", + }, + { + name: "Pano Maria" + }, + { + name: "David Chaves-Fraga" + }, + { + name: "Anastasia Dimou" + }, + ], + edDraftURI: "https://w3id.org/rml/fnml/spec/", + editors: [ + { + name: "Ben De Meester", + company: "Ghent University – imec – IDLab", + url: "https://ben.de-meester.org/#me", + orcid: "0000-0003-0248-0987", + companyURL: "https://knows.idlab.ugent.be/" + } + ], + formerEditors: [ + { + name: "Anastasia Dimou", + url: "https://natadimou.com/#me", + orcid: "0000-0003-2138-7972", + } + ], + github: "https://github.com/kg-construct/rml-fnml", + latestVersion: null, + license: "w3c-software-doc", + localBiblio: { + RML: { + title: "RDF Mapping Language (RML)", + href: "https://rml.io/specs/rml/", + status: "Unofficial Draft", + publisher: "IDLab - imec - Ghent University", + date: "08 October 2020", + }, + FnO: { + title: "Function Ontology (FnO)", + href: "https://w3id.org/function/spec/", + status: "Unofficial Draft", + publisher: "IDLab - imec - Ghent University", + date: "10 November 2021", + }, + CollectionsContainers: { + title: "Collections and Containers in RML", + href: "https://w3id.org/kg-construct/collections-containers", + status: "Unofficial Draft", + publisher: "Knowledge Graph Construction W3C Community Group ", + date: "16 August 2022", + }, + }, + otherLinks: [ + { + key: "Website", + data: [{ + value: "https://rml.io", + href: "https://rml.io" + }, + { + value: "https://fno.io", + href: "https://fno.io" + }] + }, + ], + // shortName: "RML-FNML", + specStatus: "CG-DRAFT", + // W3C config + copyrightStart: "2021", + doJsonLd: true, + group: "kg-construct", +}; \ No newline at end of file diff --git a/spec/docs/index.html b/spec/docs/index.html index 2fd0143..7a32e0e 100644 --- a/spec/docs/index.html +++ b/spec/docs/index.html @@ -5,89 +5,93 @@ RML-FNML - @@ -128,4 +132,4 @@ - + \ No newline at end of file diff --git a/spec/docs/overview.md b/spec/docs/overview.md index 52e34bf..5b5c61c 100644 --- a/spec/docs/overview.md +++ b/spec/docs/overview.md @@ -28,7 +28,10 @@ where we want to perform an uppercase operation to a set of fields. The FnO description of the function [toUppercase](https://github.com/OpenRefine/OpenRefine/wiki/GREL-String-Functions#touppercasestring-s) is as follows: -```turtle "example": "toUppercase FnO description" + + The execution of such a function converts a string to its uppercase sibling, so `test` becomes `TEST` and `This is an input STRING.` becomes `THIS IS AN INPUT STRING.`. The latter would be described as follows using an FnO Execution description: -```turtle "example": "toUppercase FnO execution description" + + ## FNML Example - shortcuts To connect this function with the RML mapping document, we make use of FNML, see below for an example, which makes maximal use of shortcuts. @@ -104,7 +116,10 @@ graph LR
Visual overview of connections FNML
-```turtle "example": "using toUppercase in an RML mapping" + + The `name`-value is not referenced directly, instead, its value is used as `grel:valueParam`-parameter for the `grel:toUppercase`-function. @@ -143,7 +161,10 @@ We make use of an intermediate [=Function-valued Expression Map=] so that we can The same example, but written without shortcuts, is as follows: -```turtle "example": "using toUppercase in an RML mapping without shortcuts" + diff --git a/spec/docs/problem.md b/spec/docs/problem.md index 61ba9f3..cf62715 100644 --- a/spec/docs/problem.md +++ b/spec/docs/problem.md @@ -13,7 +13,10 @@ but we want the resulting knowledge to have uppercase values. The following [=RML Mapping=] contains the descriptions to generate a knowledge graph from a data source, but no data transformations. -```turtle "example": "RML Mapping without data transformations" + diff --git a/spec/resources/example-condition.ttl b/spec/resources/example-condition.ttl new file mode 100644 index 0000000..dbb6914 --- /dev/null +++ b/spec/resources/example-condition.ttl @@ -0,0 +1,69 @@ +@prefix dbo: . +@prefix fns: . +@prefix rml: . + +<#Person_Mapping> + rml:logicalSource <#LogicalSource> ; + rml:subjectMap <#SubjectMap> ; + rml:predicateObjectMap <#NameMapping> . + +# Suggestion: add rml:condition predicate to expression map, +# and conforming mapping engines MUST support following functions: +# - isNull, isNotNull, equals, noEquals, IF +# (isNotNull and IF are defined below, rest is an excercise for the reader) +<#NameMapping> + rml:predicate dbo:title ; + # A condition can be defined in any expression map + rml:objectMap [ + # new predicate that links to a function-valued expression map, + # that function MUST return a boolean + rml:condition [ + rml:functionExecution [ + # isNotNull(parameter: X) / definition: X != NULL ? TRUE : FALSE ; + rml:function fns:isNotNull ; + rml:input [ + # The parameter that is checked for NULL + rml:parameter fns:parameter ; + rml:inputValueMap [ + rml:reference "name" + ] + ] + ] ; + rml:return fns:boolOut # if fno:boolOut is the first specified return, this triple can be ommitted. + ] ; + # The actual expression used if the condition returns TRUE + rml:constant "[a filled in title]" + ] . + +# This is actually a shortcut to the following +<#NameMappingExtended> + rml:predicate dbo:title ; + rml:objectMap [ + rml:functionExecution [ + # IF(bool: X, expression: Y) + # Function definition: X === TRUE ? Y : NULL + rml:function fns:IF ; + rml:input [ + # = original condition function + rml:parameter fns:boolParameter ; + rml:inputValueMap [ + rml:function fns:isNotNull ; + rml:input [ + rml:parameter fns:parameter ; + rml:inputValueMap [ + rml:reference "name" + ] + ] + ] + ] , [ + # = original expression + rml:parameter fns:expressionParameter ; + rml:inputValueMap [ + rml:constant "[a filled in title]" + ] + ] + ] ; + ] . +# Any custom function can be used, +# or nested functions (eg AND/OR), +# depending on what the engines support