-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-collection.ttl
38 lines (35 loc) · 1.48 KB
/
02-collection.ttl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{# Template '02-collection.ttl'
Description: 'This template shows how to create and apply a translation map from one of the input sets;
and does so in classic iteration mode.'
Author: Marc Portier
Date: 08/03/2022
Target vocabs:
- ex: <https://example.org/02-collection/>
Inputs:
- input-file: (None)
- set-file(s):
- data_countries.csv as countries,
- data.csv as _
- mode: iteration,
#}
{% if ctrl.isFirst %}
@prefix ex: <https://example.org/02-collection/> .
ex:fullset ex:iteration {{ctrl.settings.iteration | ttl("xsd:boolean")}};
ex:ctrl-first {{ctrl.isFirst | ttl("xsd:boolean")}};
ex:ctrl-last {{ctrl.isLast | ttl("xsd:boolean")}};
ex:ctrl-index {{ctrl.index | ttl("xsd:integer")}}.
{% endif -%}
{%- set ctrymap = map(sets['countries'], 'Alpha-3 code', None, 'ctrymap') -%}
{#- note: using the cache-key in the map() construct avoids duplicate work in iteration mode #}
{%- set nothing = ctrymap.apply(_, 'country', 'country_info') -%}
<{{uritexpand("https://vliz.be/code/pysubyt/test/item{#id}",_)}}>
ex:name "{{_.name}}"^^xsd:string;
ex:country "{{_.country_info['Alpha-2 code']}}"^xsd:string.
{% if ctrl.isLast %}
{%- for country in sets['countries'] -%}
{%- if country['Alpha-2 code'] == 'BE' -%}
<{{uritexpand("https://iso.org/countries{/Alpha-2 code}", country)}}> ex:name {{country['English short name lower case'] | ttl('@en')}}.
{# force newline #}
{%- endif -%}
{%- endfor %}
{%- endif %}