@@ -11,6 +11,8 @@ Table of contents:
1111 * [ Specifying sources] ( #specifying-sources )
1212 * [ Adding variable type] ( #adding-variable-type )
1313 * [ Templated queries] ( #templated-queries )
14+ * [ Templated queries with fixed values for the template variables] ( #templated-queries-with-fixed-values-for-the-template-variables )
15+ * [ Templated queries with values for the template variables to be derived from the data] ( #templated-queries-with-values-for-the-template-variables-to-be-derived-from-the-data )
1416 * [ Query icons] ( #query-icons )
1517* [ Custom queries] ( #custom-queries )
1618* [ Representation Mapper] ( #representation-mapper )
@@ -120,8 +122,16 @@ The configuration file follows a simple structure.
120122 },
121123 "variables" : {
122124 "variableExampleString" : [" \" String1\" " , " \" String2\" " ],
123- "variableExampleUri" : [" <https://example.com/uri1>" , " <https://example.com/uri2>" ]
125+ "variableExampleUri" : [" <https://example.com/uri1>" , " <https://example.com/uri2>" ],
126+ "variableExampleInteger" : [" 1" , " 2" ]
124127 },
128+ "indirectVariables" : {
129+ "queryLocations" : [
130+ " Path to the location, relative to 'queryFolder' of a query yielding some template variable values" ,
131+ ...
132+ ]
133+ },
134+
125135 "askQuery" : {
126136 "trueText" : " The text that is to be shown when the query result is true (in ASK queries)." ,
127137 "falseText" : " The text that is to be shown when the query result is false (in ASK queries)."
@@ -159,18 +169,51 @@ The underscore `_` here is crucial to make a clear distinction between name and
159169
160170### Templated queries
161171
162- This application supports queries whose contents are not completely fixed upfront: they contain variables whose value can be set interactively.
172+ This application supports templated queries: queries whose contents are not completely fixed upfront.
173+ They can contain * template variables* .
174+ A template variable is an identifier preceded by a ` $ ` sign, e.g. ` $genre ` .
175+ Before submitting the SPARQL query, each template variable will be replaced by the actual value assigned to it interactively.
176+
177+ #### Templated queries with fixed values for the template variables
163178
164- To change a query into a templated query:
165- - replace the fixed portion(s) of the query with (a) variable(s); a variable is an identifier preceded by a ` $ ` sign, e.g. ` $genre `
166- - add a ` variables ` object in the query's entry in the configuration file
167- - in the ` variables ` object, for each variable, add a property with name equal to the variable's identifier
168- - set each such property's value to an array of possible values for the corresponding variable
179+ If all possible values for the template variables are fixed and hence can be written in the config file, proceed as follows.
169180
170- Note that variables' values are not restricted to strings: URIs for example are alo possible.
181+ - Replace the fixed portion(s) of the original query with (a) template variable(s).
182+ - In the config file:
183+ - Add a ` variables ` object in the query's entry in the configuration file.
184+ - In the ` variables ` object, for each template variable, add a property with name equal to the template variable's identifier.
185+ - Set each such property's value to an array strings, where each string is a possible value for the corresponding template variable.
186+
187+ Note that template variables' values are not restricted to strings: URIs for example are also possible.
171188As a consequence, for strings the surround double quotes ` " ` must be added to the values in the list.
189+ For URIs you must add surrounding angle brackets ` <> ` .
190+ Other literals (integers for example) don't have to be surrounded with extra delimiters.
172191This is shown in the configuration structure above.
173192
193+ #### Templated queries with values for the template variables to be derived from the data
194+
195+ In most cases, the values for the template variables are not fixed, but depend on * the data to query* .
196+ For those cases, these values can be specified indirectly, by referring to one or more auxiliary queries.
197+ Proceed as follows.
198+
199+ - Write one or more auxiliary queries that yield the values of the template variable(s).
200+ The variable names in the SELECT statement must match the template variable names (e.g ` ?genre ` for template variable ` $genre ` ).
201+ - Replace the fixed portion(s) of the original query with (a) template variable(s).
202+ - In the config file:
203+ - Add an ` indirectVariables ` object in the query's entry in the configuration file.
204+ - In the ` indirectVariables ` object, add a property ` queryLocations ` : this must be an * array* ,
205+ listing the location(s) of the one or more auxiliary queries that you wrote.
206+
207+ An example auxiliary query for the variable ` $genre ` , as used in one of the provided example templated queries:
208+
209+ ``` text
210+ PREFIX schema: <http://schema.org/>
211+
212+ SELECT DISTINCT ?genre WHERE {
213+ ?list schema:genre ?genre;
214+ }
215+ ```
216+
174217### Query icons
175218
176219In the selection menu the name of the query is proceeded by an icon.
0 commit comments