swpExamples.ttl
11.1 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# baseURI: http://uispin.org/examples/swpExamples
# imports: http://topbraid.org/countries
# imports: http://uispin.org/uix
@prefix arg: <http://spinrdf.org/arg#> .
@prefix ex: <http://uispin.org/examples/swpExamples#> .
@prefix fn: <http://www.w3.org/2005/xpath-functions#> .
@prefix html: <http://uispin.org/html#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix spin: <http://spinrdf.org/spin#> .
@prefix spl: <http://spinrdf.org/spl#> .
@prefix ui: <http://uispin.org/ui#> .
@prefix uix: <http://uispin.org/uix#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
arg:letter
rdf:type rdf:Property ;
rdfs:label "letter"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
<http://uispin.org/examples/swpExamples>
rdf:type owl:Ontology ;
owl:imports <http://topbraid.org/countries> , <http://uispin.org/uix> ;
owl:versionInfo "Created with TopBraid Composer"^^xsd:string .
ex:ExpressionExample1
rdf:type uix:Example ;
rdfs:comment "Any SPARQL expression can be embedded into an SWP document wrapped by {= ... }"^^xsd:string ;
rdfs:label "The {= ... } Notation: SPARQL Expressions"^^xsd:string ;
rdfs:subClassOf ex:ExpressionExamples ;
ui:prototype
[ rdf:type html:Div ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text "The answer is "^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 1 ;
ui:text [ rdf:type sp:add ;
sp:arg1 20 ;
sp:arg2 22
]
]
] ;
uix:level 1 ;
uix:queryGraph <http://topbraid.org/countries> .
ex:ExpressionExamples
rdf:type uix:Example ;
rdfs:label "Expression examples"^^xsd:string ;
rdfs:subClassOf uix:Examples ;
uix:level 1 .
ex:ForEachExample1
rdf:type uix:Example ;
rdfs:label "Iterating: ui:forEach"^^xsd:string ;
rdfs:subClassOf ex:ResultSetExamples ;
ui:prototype
[ rdf:type html:Div ;
ui:child
[ rdf:type html:H3 ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text "Countries of the World"^^xsd:string
] ;
ui:childIndex 0
] ;
ui:child
[ rdf:type html:Ul ;
ui:child
[ rdf:type ui:forEach ;
ui:child
[ rdf:type html:Li ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text [ sp:varName "label"^^xsd:string
]
] ;
ui:childIndex 0
] ;
ui:childIndex 0 ;
ui:resultSet
[ rdf:type sp:Select ;
sp:orderBy ([ sp:varName "label"^^xsd:string
]) ;
sp:resultVariables ([ sp:expression
[ rdf:type ui:label ;
sp:arg1 [ sp:varName "country"^^xsd:string
]
] ;
sp:varName "label"^^xsd:string
]) ;
sp:where ([ sp:object <http://topbraid.org/countries#Country> ;
sp:predicate rdf:type ;
sp:subject
[ sp:varName "country"^^xsd:string
]
])
]
] ;
ui:childIndex 1
]
] ;
uix:level 2 ;
uix:queryGraph <http://topbraid.org/countries> .
ex:FunctionCallExample1
rdf:type uix:Example ;
rdfs:comment "To insert the result of a SPARQL function call, use the {= ... } notation."^^xsd:string ;
rdfs:label "The {= ... } Notation: Function calls"^^xsd:string ;
rdfs:subClassOf ex:ExpressionExamples ;
ui:prototype
[ rdf:type html:Div ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text "Country code: "^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 1 ;
ui:text [ rdf:type spl:object ;
sp:arg1 <http://topbraid.org/countries#DE> ;
sp:arg2 <http://topbraid.org/countries#abbreviation>
]
]
] ;
uix:level 4 ;
uix:queryGraph <http://topbraid.org/countries> .
ex:GetSortedCountriesStartingWithLetter
rdf:type spin:SelectTemplate ;
rdfs:label "Get sorted countries starting with letter"^^xsd:string ;
rdfs:subClassOf spin:SelectTemplates ;
spin:body
[ rdf:type sp:Select ;
sp:orderBy ([ sp:varName "label"^^xsd:string
]) ;
sp:resultVariables ([ sp:varName "label"^^xsd:string
]) ;
sp:where ([ sp:object <http://topbraid.org/countries#Country> ;
sp:predicate rdf:type ;
sp:subject
[ sp:varName "country"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type ui:label ;
sp:arg1 [ sp:varName "country"^^xsd:string
]
] ;
sp:variable
[ sp:varName "label"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type fn:starts-with ;
sp:arg1 [ rdf:type fn:lower-case ;
sp:arg1 [ sp:varName "label"^^xsd:string
]
] ;
sp:arg2 [ rdf:type fn:lower-case ;
sp:arg1 [ sp:varName "letter"^^xsd:string
]
]
]
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The letter the country has to start with."^^xsd:string ;
spl:predicate arg:letter ;
spl:valueType xsd:string
] .
ex:ResultSetExamples
rdf:type uix:Example ;
rdfs:label "Result set examples"^^xsd:string ;
rdfs:subClassOf uix:Examples ;
uix:level 2 .
ex:TemplateCallExample
rdf:type uix:Example ;
rdfs:comment "Reusable queries can be stored in SPIN templates. ui:call is used to execute those templates with the provided arguments. The result is a result set (by default called ?rs) that can be processed in the children of the ui:call element."^^xsd:string ;
rdfs:label "Template call example"^^xsd:string ;
rdfs:subClassOf ex:ResultSetExamples ;
ui:prototype
[ rdf:type html:Div ;
ui:child
[ rdf:type html:H3 ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text "Countries starting with A"^^xsd:string
] ;
ui:childIndex 0
] ;
ui:child
[ rdf:type html:Ul ;
ui:child
[ rdf:type ui:call ;
arg:letter "a"^^xsd:string ;
ui:child
[ rdf:type ui:forEach ;
ui:child
[ rdf:type html:Li ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text [ sp:varName "label"^^xsd:string
]
] ;
ui:childIndex 0
] ;
ui:childIndex 0 ;
ui:resultSet
[ sp:varName "rs"^^xsd:string
]
] ;
ui:childIndex 0 ;
ui:template ex:GetSortedCountriesStartingWithLetter
] ;
ui:childIndex 1
]
] ;
uix:level 3 ;
uix:queryGraph <http://uispin.org/examples/swpExamples> .