RML-FNML

Draft Community Group Report

Latest published version:
none
Latest editor's draft:
https://w3id.org/rml/fnml/spec/
Previous version:
https://kg-construct.github.io/rml-fnml/spec/docs/20251107/
Editor:
Ben De Meester (Ghent University – imec – IDLab)
Former editor:
Anastasia Dimou
Authors:
Ben De Meester
Samaneh Jozashoori
Pano Maria
David Chaves-Fraga
Anastasia Dimou
Feedback:
GitHub kg-construct/rml-fnml (pull requests, new issue, open issues)
Website
https://rml.io
https://fno.io

Abstract

RML+FnO is an approach to provide for data transformations when generating knowledge graphs from (semi-)structured data using the RDF Mapping Language (RML).

In RML+FnO, data transformations are defined declaratively, supporting the Function Ontology (FnO).

This approach is not case-specific: data transformations are independent of their implementation and thus interoperable, while the functions are decoupled and reusable. This allows developers to improve the generation framework independent from the contributors that focus on generating the knowledge graphs.

Status of This Document

This specification was published by the Knowledge Graph Construction Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.

GitHub Issues are preferred for discussion of this specification.

1. Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

The key words MAY and MUST in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

2. The Problem

Mapping languages allow us to define how knowledge graphs are generated from (semi-)structured data, but only if the original data values can be used as-is. Complex data transformations in mapping languages typically are either implemented as custom solutions, or are done by systems separate from the mapping process. The former data transformations remain case-specific, often coupled with the mapping, whereas the latter is not reusable across systems.

For example, we have a data source where all names are lowercase, 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.

3. Definitions

3.1 Generic

[RML]-independent defintions:

3.2 RML

Definitions taken from [RML] or R2RML: RDB to RDF Mapping Language:

Within this specification, the Expression Map definition is extended by adding new possible properties and thus also a new type of Expression Map. The change is included below with changes highlighted in bold.


An Expression Map can have the following properties:


3.3 FNML

Note

It is currently assumed that a Function-valued Expression Map always returns an RDF term [rdf-concepts]. How a list of RDF terms is handled, is out of scope of this spec, but discussed at Collections and Containers in RML.

5. FNML

We use terms defined in the FNML ontology to link [RML] with [FNO].

The ontology namespace is http://w3id.org/rml/, the preferred prefix is rml:. See below for how FNML introduced terms align with RML Core.

FNML diagram
Figure 2 Visual overview of how FNML introduced terms align with RML Core

5.1 Function-valued Expression Map

A Function-valued Expression Map is an Expression Map that is represented by a resource that has exactly one rml:functionExecution. The value of the rml:functionExecution property must be a valid Execution.

As a consequence, the default [RML] processing is extended, specifically concerning the default term type depending on whether the Term Map is an Object Map or not, namely, the Function-valued Expression Maps default term type is rml:Literal. The change is included below with changes highlighted in bold.


If the Term Map does not have a rml:termType property, then its term type is:


A Function-valued Expression Map MUST have exactly one rml:functionExecution relation. Further, it MAY have following relations specified:

Issue

A proper term map definition in RML is pending. For now, we refer to the R2RML spec, but it is assumed these references will be updated based on the evolution of RML. This also means that all changes to existing definitions such as term type etc. are complementary to this specification.

5.2 rml:ReturnMap

See Return map.

5.3 rml:FunctionExecution

See Function Execution.

5.4 rml:FunctionMap

See Function map.

5.5 rml:Input

See Input.

5.6 rml:ParameterMap

See Parameter map.

5.7 rml:functionExecution

Links function-valued expression map with Function Execution.

Domain: rml:ExpressionMap

Range: rml:FunctionExecution

5.8 rml:returnMap

Links function-valued expression map with Return map.

Domain: rml:ExpressionMap

Range: rml:ReturnMap

5.8.1 rml:return

constant expression shortcut property of rml:returnMap.

5.9 rml:functionMap

Links a Function Execution with Function.

Domain: rml:FunctionExecution

Range: rml:FunctionMap

5.9.1 rml:function

constant expression shortcut property of rml:functionMap.

5.10 rml:input

Links Execution with Inputs

5.11 rml:parameterMap

Links Input with Parameter map.

Domain: rml:Input

Range: rml:ParameterMap

5.11.1 rml:parameter

constant expression shortcut property of rml:parameterMap

5.12 rml:inputValueMap

Links Input with a term map.

Domain: rml:Input

Range: rml:TermMap

5.12.1 rml:inputValue

constant expression shortcut property of rml:inputValueMap

Best Practice 1: Joining using data transformations

When you specifically want to have join conditions, you should use functions within rml:joinCondition, see, e.g. test case RMLFNOTC0019.

6. Advanced usage

6.1 Multivalue processing

Aligned with the other RML specifications, multivalue expression evaluation results are processed in sequence. So, if a multivalue expression evaluation contains the multivalue "a", "b", and "c", the function is applied to each individual value in that order.

6.2 Nested functions

As the values of a function are represented using Expression Maps, it is possible to nest functions: you generate a term in a first function, and that term is used as an parameter value in a second function.

Issue

For an old example, see RMLFNOTC0018.

Issue 3: Feature: how to nest a joincondition inside a function?

For now, it is unclear how to handle a nested function where that nested Triples Map contains a join condition.

6.3 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:

Note: Condition function definitions

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

6.3.1 Multivalue Conditions - example

Let's take following example data

[
    {
        "conditionValue": [1, 0, 5],
        "values": ["a", "b", "c"]
    }
]

If we execute following RML mapping

This will result in two triples, because in conditionValue you have two valid condition executions

<subject> ex:id "df2c61cc-6fad-435d-aa95-10761840478b" .
<subject> ex:id "44d01ee9-448f-4804-acc8-3272939494b0" .

A. References

A.1 Normative references

[FnO]
Function Ontology (FnO). IDLab - imec - Ghent University. 10 November 2021. Unofficial Draft. URL: https://w3id.org/function/spec/
[R2RML]
R2RML: RDB to RDF Mapping Language. Souripriya Das; Seema Sundara; Richard Cyganiak. W3C. 27 September 2012. W3C Recommendation. URL: https://www.w3.org/TR/r2rml/
[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc2119
[RFC8174]
Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words. B. Leiba. IETF. May 2017. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc8174
[RML]
RDF Mapping Language (RML). IDLab - imec - Ghent University. 08 October 2020. Unofficial Draft. URL: https://rml.io/specs/rml/

A.2 Informative references

[CollectionsContainers]
Collections and Containers in RML. Knowledge Graph Construction W3C Community Group. 16 August 2022. Unofficial Draft. URL: https://w3id.org/kg-construct/collections-containers
[rdf-concepts]
Resource Description Framework (RDF): Concepts and Abstract Syntax. Graham Klyne; Jeremy Carroll. W3C. 10 February 2004. W3C Recommendation. URL: https://www.w3.org/TR/rdf-concepts/