-
Notifications
You must be signed in to change notification settings - Fork 0
/
norse.ttl
144 lines (119 loc) · 4.35 KB
/
norse.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
PREFIX eg: <http://www.example.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX fno: <https://w3id.org/function/ontology#>
PREFIX fnoi: <https://w3id.org/function/vocabulary/implementation#>
PREFIX fnox: <https://w3id.org/aksw/fnox#>
PREFIX norse: <https://w3id.org/aksw/norse#>
# Important: FNO appears to have several limitations:
# (.) No support for ellipsis
# (.) No function overloads
# (.) No recommendation for union types
# (.) No support for property functions (a.k.a. magic predicates)
##
# JSON
##
norse:json
a rdfs:Datatype ;
rdfs:subClassOf rdfs:Literal ;
rdfs:isDefinedBy norse: ;
rdfs:label "JSON" ;
rdfs:comment "A JSON datatype suitable for use with 'norse' functions" ;
.
norse:json.get a fno:Function ;
rdfs:label "json.get" ;
rdfs:comment "Return a JSON object's value for a given key" ;
fno:expects (
[ fno:type norse:json ; fno:required true ]
[ fno:type xsd:string ; fno:required true ] # Actually integer would work for json arrays...
) ;
fno:returns ( rdfs:Literal ) ;
.
norse:json.path a fno:Function ;
rdfs:label "json.path" ;
rdfs:comment "Return the value of evaluating a JSON path against the given JSON element" ;
fno:expects (
[ fno:type norse:json ; fno:required true ]
[ fno:type xsd:string ; fno:required true ]
) ;
fno:returns ( rdfs:Literal ) ;
.
norse:json.js a fno:Function ;
rdfs:label "json.js" ;
rdfs:comment "Invoke a javascript function (specified as a string) with the given arguments" ;
fno:expects (
[ fno:type xsd:string ; fno:required true ]
[ fno:type rdfs:Resource ; fnox:ellipsis true ]
) ;
fno:returns ( rdfs:Literal ) ;
.
norse:json.object a fno:Function ;
rdfs:label "JSON object" ;
rdfs:comment "Create a json object from the given arguments. Every consecutive pair of arguments is treated as key and corresponding value." ;
fno:expects (
[ fno:type rdfs:Resource ; fnox:ellipsis true ]
) ;
fno:returns ( norse:json ) ;
.
norse:json.array a fno:Function ;
rdfs:label "JSON array" ;
rdfs:comment "Create a json array from the given arguments. RDF literals are converted to the corresponding JSON representation if it exists. Otherwise STR() is implicitly applied." ;
fno:expects (
[ fno:type rdfs:Resource ; fnox:ellipsis true ]
) ;
fno:returns ( norse:json ) ;
.
norse:json.entries a fno:Function ;
rdfs:label "JSON entries" ;
rdfs:comment """Convert all of a JSON object's key-value entries into a JSON array of { "key": ..., "value": ...} objects.""" ;
fno:expects (
[ fno:type norse:json ; fno:required true ]
) ;
fno:returns ( norse:json ) ;
.
norse:json.explode a fnox:PropertyFunction ;
rdfs:label "JSON explode" ;
rdfs:comment "Bind elements of a JSON array (starting with a configurable offset) to a given list of SPARQL variables" ;
eg:exampleUsage """(["this", "is", 1, "array"]^^xsd:json, 1) norse:json.explode (?is ?one ?array)""" ;
fnox:expectsSubjects (
[ fno:type norse:json ; fno:required true ]
[ fno:type xsd:integer ; fno:required false ]
) ;
fnox:expectsObjects (
[ fno:type rdfs:Resource ; fno:require true ] # Typically the output variable
) ;
.
norse:json.unnest a fnox:PropertyFunction ;
rdfs:label "JSON unnest" ;
rdfs:comment "Unnest a json array into a " ;
fnox:expectsSubjects ([ fno:type norse:json ; fno:required true ]) ;
fnox:expectsObjects (
[ fno:type rdfs:Resource ; fno:require true ] # Typically the output variable
[ fno:type xsd:integer ; fno:required false ] # The array index - can be used for either for input or output
) ;
.
##
# XML
##
norse:xml
a rdfs:Datatype ;
rdfs:subClassOf rdfs:Literal ;
rdfs:isDefinedBy norse: ;
rdfs:label "XML" ;
rdfs:comment "An XML datatype suitable for use with 'norse' functions" ;
.
norse:xml.unnest a fnox:PropertyFunction ;
rdfs:label "XML unnest" ;
rdfs:comment "Unnest an XML node against a given XPath expression (as xsd:string)" ;
fnox:expectsSubjects ([ fno:type norse:xml ; fno:required true ]) ;
fnox:expectsObjects (
[ fno:type xsd:string ; fno:require true ] # Typically the output variable
[ fno:type xsd:integer ; fno:required false ] # The array index - can be used for either for input or output
) ;
.
##
# Maven (essentially maven style IRI-to-URN conversion)
##
norse:mvn.toPath
a fno:Function ;
.