Skip to content

Commit

Permalink
updated conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdmeest committed Aug 14, 2024
1 parent 9d8af3d commit db05bae
Showing 1 changed file with 65 additions and 24 deletions.
89 changes: 65 additions & 24 deletions spec/docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
</p>

```turtle "example": "use nested function"
<aside class="example" id="example-nested-function" title="usage of nested function">
<aside class="ex-mapping">

```turtle
@prefix dbo: <http://dbpedia.org/ontology/> .
@prefix grel: <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .
@prefix rml: <http://w3id.org/rml/> .
Expand Down Expand Up @@ -65,46 +68,79 @@ For now, it is unclear how to handle a nested function where that nested Triples
] .
```

</aside>
</aside>

### Conditions

Conditions are a shortcut to make RML documents more intuitive, but rely on existing FNML functionality.
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

<p class="note" title="Condition function definitions">
isNotNull and IF are defined below, rest is an excercise for the reader.
The actual FnO definitions are TODO.
</p>

<aside class="example" id="example-condition" title="usage of condition">
<aside class="ex-mapping">

```turtle "example": "use condition"
```turtle
@prefix dbo: <http://dbpedia.org/ontology/> .
@prefix grel: <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .
@prefix fns: <http://example.com/fns#> .
@prefix rml: <http://w3id.org/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 [
# 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: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 "true"
rml:constant "[a filled in title]"
] .
```
</aside>

This is actually a shortcut to the following

<aside class="ex-mapping">

```turtle
@prefix dbo: <http://dbpedia.org/ontology/> .
@prefix fns: <http://example.com/fns#> .
@prefix rml: <http://w3id.org/rml/> .
<#Person_Mapping>
rml:logicalSource <#LogicalSource> ;
rml:subjectMap <#SubjectMap> ;
rml:predicateObjectMap <#NameMappingExtended> .
# This is actually a shortcut to the following
<#NameMappingExtended>
rml:predicate dbo:title ;
rml:objectMap [
Expand All @@ -116,19 +152,21 @@ Conditions are a shortcut to make RML documents more intuitive, but rely on exis
# = original condition function
rml:parameter fns:boolParameter ;
rml:inputValueMap [
rml:function fns:isNotNull ;
rml:input [
rml:parameter fns:parameter ;
rml:inputValueMap [
rml:reference "name"
rml:functionExecution [
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 "true"
rml:constant "[a filled in title]"
]
]
] ;
Expand All @@ -137,3 +175,6 @@ Conditions are a shortcut to make RML documents more intuitive, but rely on exis
# or nested functions (eg AND/OR),
# depending on what the engines support
```

</aside>
</aside>

0 comments on commit db05bae

Please sign in to comment.