/
page-templates-syntax.html
379 lines (345 loc) · 10.5 KB
/
page-templates-syntax.html
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
---
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
title: "Page Templates Syntax"
redirect_from:
- /documentation/reference/page-templates-syntax.html
---
<p>
This document is a reference to the elements of the Page Template XML format.
Refer to the <a href="../page-templates.html">Introduction to Page Templates</a>.
</p><p>
A page template describes a particular way or set of ways of organizing data from some sources on a page.
It has the following structure:
</p>
<pre>
<<a href="#page">page</a> id="<a href="#id">[id]</a>"> <em><!-- The top-level section of this page --></em>
[page-element]*
</page>
</pre>
<p>
…where each <code>[page-element]</code> is one of:
</p>
<dl>
<dt><<a href="#section">section</a>>[page-element]*</section></dt>
<dd><em>A nested section (screen area)</em></dd>
<dt><<a href="#source">source</a> name="[source-name]"> [renderer]* [parameter]* </source></dt>
<dd><em>A data source which should be placed in this section</em></dd>
<dt><<a href="#renderer">renderer</a> name="[renderer-name]"> [parameter]* </renderer></dt>
<dd><em>The renderer to use for the source or section containing this</em></dd>
<dt><<a href="#choice">choice</a>> [map] or [page-element]/[alternative]* </choice></dt>
<dd><em>A choice between alternative page elements resolved at runtime</em></dd>
<dt><placeholder id="[id]"/></dt>
<dd><em>an element to be replaced by a map item at runtime</em></dd>
<dt><<a href="#include">include</a> idref="[page-id]">/></dt>
<dd><em>Include the page elements contained in another page</em></dd>
</dl>
<p>
where the nested elements above are:
</p>
<dl>
<dt><parameter name="[name]">[value]</parameter></dt>
<dd>
<em>A parameter of the owning element. Renderer parameters are sent
as-is to the frontend in the result. Source parameters are sent to
the source by setting the query
parameter<code>source.[sourceName].[name]</code>.</em>
</dd>
<dt><alternative> [page-element]* </alternative></dt>
<dd><em>multiple page elements constituting one choice alternative</em></dd>
<dt><<a href="#map">map</a> to="placeholder-id1 placeholder-id2 …"> [page-element]/[item]* </alternative></dt>
<dd><em>a mapping of some page elements to placeholders</em></dd>
<dt><<a href="#item">item</a>> [page-element]* </item></dt>
<dd><em>multiple page elements which should all map to one placeholder</em></dd>
</dl>
<p>
All tags may also include a <code>description</code> attribute to document the use of the tag.
Tags and attributes are described in detail in the following.
</p>
<h2 id="id">id</h2>
<p>
An id has the format:
</p>
<pre>
id ::= name(:major(.minor(.micro(.qualifier)?)?)?)?
name ::= <em>identifier</em>
major ::= <em>integer</em>
minor ::= <em>integer</em>
micro ::= <em>integer</em>
qualifier ::= <em>identifier</em>
</pre>
<p>
Any omitted numeric version component missing is taken to mean 0,
while a missing qualifier is taken to mean the empty string.
</p>
<h2 id="page">page</h2>
<p>
The root tag of a page template. Defines a page, is also its root section.
Attributes and subtags are the same as for <a href="#section">section</a>,
with the exception that the <code>id</code> attribute is mandatory for a page.
</p>
<h2 id="section">section</h2>
<p>
A representation of an area of screen real-estate.
At runtime a section will contain content from various sources.
The final renderer will render the section with its data items
and/or subsections in an area of screen real-estate determined by its containing tag.
</p>
<table class="table">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>A unique identifier of this section used for referring.</td>
<td><em>No id</em></td>
</tr>
<tr>
<td>layout</td>
<td>An identifier. Permissible values
are <code>row</code>, <code>column</code> and any additional
layouts supported by the renderer i of the returned page.</td>
<td><code>column</code></td>
</tr>
<tr>
<td>region</td>
<td>An identifier. The permissible values, and whether this is
mandatory is determined by the particular layout identifier of
the containing section (<code>row</code> and <code>column</code>
does not specify any region identifiers).</td>
<td><em>None</em></td>
</tr>
<tr>
<td>source
<td>A space-separated set of sources permissible within this. This
is a shorthand for defining sources as subtags. The total source
list of this section consists of both the sources listed here
and as subtags.</td>
<td><em>All sources are permissible if none are specified.</em></td>
</tr>
<tr>
<td>max
<td>The maximum number of items permissible within this section
(including any subsections). Regardless of the blending method
used, the most relevant items are kept.</td>
<td><em>Unrestricted</em></td>
</tr>
<tr>
<td>min</td>
<td>The minimum number of items desired within this.</td>
<td><em>Unrestricted</em></td>
</tr>
<tr>
<td>order</td>
<td>The method of ordering to use on the items displayed in this
container. This may be any <a href="sorting.html">sorting
specification</a> over the fields of the hits, plus the source
name and relevance score, for example <code>[source]
-[relevance] category</code> to group by source, sort each group
primarily by decreasing relevance and secondarily by the
"category" field. The <code>[source]</code> identifier will sort
sources by the order in which they are listed in the template in
use.
</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="source">source</h2>
<p>
A data source whose data should be placed in the containing section.
</p>
<table class="table">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>The name of this source.</td>
<td><em>Mandatory</em></td>
</tr>
<tr>
<td>url</td>
<td>The url of this source. If this is set, the data of this source
is <em>not</em> fetched, but instead the source tag (with url)
will appear in the returned page such that the frontend may
fetch it. This is provided primarily as a migration path, as
such data can not be inspected and processed to optimize the
returned page.</td>
<td><em>No url: Fetch this configured source from the container.</em></td>
</tr>
</tbody>
</table>
<h2 id="renderer">renderer</h2>
<p>
A renderer to use to render a section of a data item (hit) of a particular type.
</p>
<table class="table">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>The name of this renderer.</td>
<td><em>Mandatory</em>
</tr>
<tr>
<td>for</td>
<td>The name of a hit type or a source this is the renderer for.</td>
<td><em>If in a section: This is the renderer for the whole
section.<br />If in a source: This is the default renderer for
hits from this source.</em></td>
</tr>
</tbody>
</table>
<h2 id="choice">choice</h2>
<p>
A choice between multiple alternative (lists of) page elements.
A resolver chooses between the possible alternatives for each request at runtime.
The <code>alternative</code> tag is used to enclose an alternative.
If an alternative consists of just one page element tag,
the enclosing alternative tag may be skipped.
</p>
<table class="table">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>method</td>
<td>the name of the method for making the choice. Must be supported
by the optimizer in use.</td>
<td><em>Any method</em></td>
</tr>
</tbody>
</table>
<h3 id="contained-tags">Contained tags</h3>
<p>
Either:
</p>
<table class="table">
<thead>
<tr>
<th>Tag</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>[page-element]</td>
<td>An alternative consisting of a single page element.</td>
<td>0-n</td>
</tr>
<tr>
<td>alternative</td>
<td>An alternative consisting of multiple page elements.</td>
<td>0-n</td>
</tr>
</tbody>
</table>
or
<table class="table">
<thead>
<tr>
<th>Tag</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#map">map</a></td>
<td>Specify all alternatives as a single mapping function.</td>
<td>0-1</td>
</tr>
</tbody>
</table>
<h2 id="map">map</h2>
<p>
Specify all the alternatives of a choice
as a mapping function of elements to placeholders.
A map is a convenience shorthand of writing many alternatives
in the case where a collection of elements should be mapped to a set of placeholders
with the constraint that each placeholder should get a unique element.
This is useful e.g. in the case where a set of sources are to be mapped to a set of sections.
</p>
<table class="table">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>to</td>
<td>A space-separated list of the placeholder id's the map values should be mapped to.
There cannot be more placeholder id's than there are values in this map (but fewer is ok).</td>
</tr>
</tbody>
</table>
<table class="table">
<thead>
<tr>
<th>Contained Tags</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>[page-element]</td>
<td>A map item consisting of a single page element to map to a placeholder.</td>
<td>0-n</td>
</tr>
<tr>
<td>item</td>
<td><p id="item">An item containing multiple page elements to be mapped to a single placeholder.</p></td>
<td>0-n</td>
</tr>
</tbody>
</table>
<h2 id="include">include</h2>
<p>
Includes the page elements contained directly in the <code>page</code>
element in the given page template (the page tag itself is not included).
Inclusion works exactly as if the <code>include</code> tag was
literally replaced by the content of the included page.
</p>
<table class="table">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>idref</td>
<td>The id specification of the page to include. Portions of the
version may be left unspecified to get the latest matching version.</td>
<td><em>(Mandatory)</em></td>
</tr>
</tbody>
</table>