forked from sbromle/RefBase-Fork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrwExplainResponse2html.xsl
More file actions
417 lines (416 loc) · 15.4 KB
/
srwExplainResponse2html.xsl
File metadata and controls
417 lines (416 loc) · 15.4 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
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:srw="http://www.loc.gov/zing/srw/" xmlns:zr="http://explain.z3950.org/dtd/2.0/" xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/" xmlns:refb="http://refbase.net/">
<!-- Author: Rob Sanderson (azaroth@liv.ac.uk)
Version: 0.6
Last Updated: 27/11/2003
Licence: GPL
Modified by: Matthias Steffens (refbase@extracts.de) -->
<xsl:output method="html" />
<xsl:template match="/srw:explainResponse">
<html>
<head>
<title>
<xsl:value-of select="srw:record/srw:recordData/zr:explain/zr:databaseInfo/zr:title" />
</title>
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" title="CSS Definition" />
<style type="text/css">
/* H2 {font-family: sans-serif; color: #990000; background-color: #CCCCCC; padding-top: 10px; padding-bottom: 10px; border: 1px solid #CCCCCC }*/
/* H3 {font-family: sans-serif; color: #990000; text-indent: 5px; border-left: solid 1px #CCCCCC; border-top: solid 1px #CCCCCC; padding-top: 5px }*/
/* .paramTable { vertical-align: top; border: 1px solid; padding: 3px; border-collapse: collapse }*/
/* .paramTable TD {border: 1px solid}*/
/* TH {border: 1px solid; background-color: #eeeeff}*/
</style>
<script language="JavaScript" type="text/javascript">
<xsl:text>
function mungeForm() {
inform = document.CQLForm;
outform = document.SRUForm;
max = inform.maxIndex.value;
cql = "";
prevIdx = 0;
// Step through elements in form to create CQL
for (var idx = 1; idx <= max; idx++) {
term = inform["term"+idx].value;
if (term) {
if (prevIdx) {
cql += " " + inform["bool" + prevIdx].value + " ";
}
if (term.indexOf(' ')) {
term = '"' + term + '"';
}
cql += inform["index" + idx].value + " " + inform["relat" + idx].value + " " + term;
prevIdx = idx;
}
}
if (!cql) {
alert("At least one term is required to search.");
return false;
}
outform.query.value = cql;
outform.submit();
return false;
}
function mungeScanForm() {
inform = document.ScanIndexes;
outform = document.ScanSubmit;
index = inform.scanIndex.value;
term = inform.term.value;
relat = inform.relat.value;
outform.scanClause.value = index + " " + relat +" \"" + term + "\""
outform.submit();
return false;
}
</xsl:text>
</script>
</head>
<body bgcolor="#FFFFFF">
<!-- page header: -->
<table class="pageheader" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This holds the title logo and info">
<tr>
<td valign="bottom" rowspan="2" align="left" width="120">
<a>
<xsl:attribute name="href">
<!-- note that the logo should point to the URL given in '$hostInstitutionURL' but this information is currently not available in the SRU explain response -->
<xsl:value-of select='srw:record/srw:recordData/zr:explain/zr:databaseInfo/zr:links/zr:link[@type="www"]' />
</xsl:attribute>
<img src="img/logo.png" alt="" border="0" />
</a>
</td>
<td>
<h2><xsl:value-of select="srw:record/srw:recordData/zr:explain/zr:databaseInfo/zr:title" /></h2>
<span class="smallup">
<a href="index.php" title="go to main page">Home</a><xsl:text> | </xsl:text>
<a href="show.php?records=all" title="show all records in the database">Show All</a><xsl:text> | </xsl:text>
<a href="simple_search.php" title="search the main fields of the database">Simple Search</a><xsl:text> | </xsl:text>
<a href="advanced_search.php" title="search all fields of the database">Advanced Search</a>
</span>
</td>
<td class="small" align="right" valign="middle"><br /></td>
</tr>
<tr>
<td>Search the SRU web service:</td>
<td class="small" align="right" valign="middle"><a href="user_login.php" title="login to the database">Login</a></td>
</tr>
</table>
<hr class="pageheader" align="center" width="95%" />
<!-- search forms: -->
<xsl:apply-templates select="srw:diagnostics" />
<table align="center" border="0" cellpadding="2" cellspacing="5" width="95%" summary="This table holds the search form">
<tr>
<td></td>
<td>
<form name="CQLForm" onsubmit="return mungeForm();">
<table align="center" border="0" cellpadding="2" cellspacing="5" class="paramTable">
<tr>
<th>Index</th>
<th>Relation</th>
<th>Term</th>
<th>Boolean</th>
</tr>
<input type="hidden" name="maxIndex">
<xsl:attribute name="value">
<xsl:value-of select="count(srw:record/srw:recordData/zr:explain/zr:indexInfo/zr:index)" />
</xsl:attribute>
</input>
<xsl:for-each select="srw:record/srw:recordData/zr:explain/zr:indexInfo/zr:index">
<!-- <xsl:sort select="." /> -->
<tr>
<td align="right">
<b><xsl:value-of select="zr:map[1]/zr:name/@set" />.<xsl:value-of select="zr:map[1]/zr:name" /></b>
<input type="hidden">
<xsl:attribute name="name">index<xsl:value-of select="position()" /></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="zr:map[1]/zr:name/@set" />.<xsl:value-of select="zr:map[1]/zr:name" /></xsl:attribute>
</input>
</td>
<td>
<select>
<xsl:attribute name="name">relat<xsl:value-of select="position()" /></xsl:attribute>
<option value="=">=</option>
<option value="exact">exact</option>
<option value="any">any</option>
<option value="all">all</option>
<option value="<"><</option>
<option value=">">></option>
<option value="<="><=</option>
<option value=">=">>=</option>
<option value="<>">not</option>
</select>
</td>
<td>
<input type="text" value="">
<xsl:attribute name="name">term<xsl:value-of select="position()" /></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="zr:title" /> (refbase: <xsl:value-of select="substring-after(@refb:index,'-')" />)</xsl:attribute>
</input>
</td>
<td>
<select>
<xsl:attribute name="name">bool<xsl:value-of select="position()" /></xsl:attribute>
<option value="and">and</option>
<option value="or">or</option>
<option value="not">not</option>
</select>
</td>
</tr>
</xsl:for-each>
</table>
</form>
<form method="GET" name="SRUForm" onsubmit="return mungeForm();">
<input type="hidden" name="query" value="" />
<input type="hidden" name="version" value="1.1" />
<input type="hidden" name="operation" value="searchRetrieve" />
<table align="center" border="0" cellpadding="2" cellspacing="5">
<tr>
<td>
<b>Record Schema:</b>
</td>
<td>
<select name="recordSchema">
<xsl:for-each select="srw:record/srw:recordData/zr:explain/zr:schemaInfo/zr:schema">
<option>
<xsl:attribute name="value">
<xsl:value-of select="@identifier" />
</xsl:attribute>
<xsl:value-of select="zr:title" />
</option>
</xsl:for-each>
</select>
</td>
</tr>
<tr>
<td>
<b>Record Packing:</b>
</td>
<td>
<select name="recordPacking">
<xsl:choose>
<xsl:when test='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:setting[@type="recordPacking"]'>
<option>
<xsl:attribute name="value">
<xsl:value-of select='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:setting[@type="recordPacking"]' />
</xsl:attribute>
<xsl:value-of select='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:setting[@type="recordPacking"]' />
</option>
</xsl:when>
<xsl:otherwise>
<option value="xml">xml</option>
<option value="string">string</option>
</xsl:otherwise>
</xsl:choose>
</select>
</td>
</tr>
<tr>
<td>
<b>Number of Records:</b>
</td>
<td>
<input type="text" name="maximumRecords">
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:default[@type="numberOfRecords"]'>
<xsl:value-of select='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:default[@type="numberOfRecords"]' />
</xsl:when>
<xsl:otherwise>
<xsl:text>1</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td>
<b>Record Position:</b>
</td>
<td>
<input type="text" name="startRecord" value="1" />
</td>
</tr>
<xsl:if test='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:supports[@type="resultSets"] != "false"'>
<tr>
<td>
<b>Result Set TTL:</b>
</td>
<td>
<input type="text" name="resultSetTTL" value="0" />
</td>
</tr>
</xsl:if>
<xsl:if test='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:supports[@type="recordXPath"] != "false"'>
<tr>
<td>
<b>Record XPath:</b>
</td>
<td>
<input type="text" name="recordXPath" value="" />
</td>
</tr>
</xsl:if>
<xsl:if test='srw:record/srw:recordData/zr:explain/zr:configInfo/zr:supports[@type="sort"] != "false"'>
<tr>
<td>
<b>Sort Keys:</b>
</td>
<td>
<input type="text" name="sortKeys" value="" />
</td>
</tr>
</xsl:if>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Search" onclick="return mungeForm();" />
</td>
</tr>
</table>
</form>
</td>
<!--
<td valign="top">
<h3>Browse</h3>
<!~~ Some browsers won't display when forms inside tables :( ~~>
<form name="ScanIndexes" onsubmit="return mungeScanForm();">
<table>
<tr>
<th>Index</th>
<th>Relation</th>
<th>Term</th>
<th>Boolean</th>
</tr>
<tr>
<td>
<select name="scanIndex">
<xsl:for-each select="srw:record/srw:recordData/zr:explain/zr:indexInfo/zr:index">
<xsl:sort select="." />
<option>
<xsl:attribute name="value"><xsl:value-of select="zr:map[1]/zr:name/@set" />.<xsl:value-of select="zr:map[1]/zr:name" /></xsl:attribute>
<xsl:value-of select="zr:title" />
</option>
</xsl:for-each>
</select>
</td>
<td>
<select name="relat">
<option value="=">=</option>
<option value="exact">exact</option>
<option value="any">any</option>
<option value="all">all</option>
<option value="<"><</option>
<option value=">">></option>
<option value="<="><=</option>
<option value=">=">>=</option>
<option value="<>">not</option>
</select>
</td>
<td>
<input name="term" type="text" value="" />
</td>
</tr>
</table>
</form>
<form name="ScanSubmit" method="GET">
<xsl:attribute name="action">http://<xsl:value-of select="srw:record/srw:recordData/zr:explain/zr:serverInfo/zr:host" />:<xsl:value-of select="srw:record/srw:recordData/zr:explain/zr:serverInfo/zr:port" />/<xsl:value-of select="srw:record/srw:recordData/zr:explain/zr:serverInfo/zr:database" /></xsl:attribute>
<table>
<tr>
<td>
<b>Response Position:</b>
</td>
<td>
<input type="text" name="responsePosition" value="1" size="5" />
</td>
</tr>
<tr>
<td>
<b>Maximum Terms:</b>
</td>
<td>
<input type="text" name="maximumTerms" value="20" size="5" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Browse" onclick="return mungeScanForm();" />
</td>
</tr>
</table>
<input type="hidden" name="operation" value="scan" />
<input type="hidden" name="scanClause" value="" />
<input type="hidden" name="version" value="1.1" />
</form>
</td>
-->
</tr>
<tr>
<td valign="top">
<b>Help:</b>
</td>
<td valign="top">
<xsl:text>This form gets dynamically created from the </xsl:text><a href="http://www.loc.gov/standards/sru/" target="top">SRU</a><xsl:text> explain response, it exposes indexes and capabilities offered by the refbase SRU server.</xsl:text>
<xsl:text> Queries must be specified as </xsl:text><a href="http://www.loc.gov/standards/sru/specs/cql.html" target="top">CQL (Common Query Language)</a><xsl:text>, an introduction to CQL is given </xsl:text><a href="http://zing.z3950.org/cql/intro.html" target="top">here</a><xsl:text>.</xsl:text>
<xsl:text> Please see the </xsl:text><a href="http://sru.refbase.net/" target="top">refbase online documentation</a>
<xsl:text> for more information about the SRU web service.</xsl:text>
</td>
</tr>
</table>
<!-- page footer: -->
<hr class="pagefooter" align="center" width="95%" />
<table class="pagefooter" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds the footer">
<tr>
<td class="small" width="105"><a href="index.php" title="go to main page">Home</a></td>
<td class="small" align="center">
<a href="sru.php" title="search the SRU web service">SRU Search</a><xsl:text> | </xsl:text>
<a href="library_search.php">
<xsl:attribute name="title">
<xsl:text>search the library of the </xsl:text><xsl:value-of select="srw:record/srw:recordData/zr:explain/zr:databaseInfo/zr:author" />
</xsl:attribute>
<xsl:text>Library Search</xsl:text>
</a><xsl:text> | </xsl:text>
<a href="show.php" title="display details for a particular record by entering its database serial number">Show Record</a><xsl:text> | </xsl:text>
<a href="extract.php" title="extract citations from a text and build an appropriate reference list">Extract Citations</a>
</td>
<td class="small" align="right" width="105"><a href="http://wiki.refbase.net/" title="display help">Help</a></td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="srw:diagnostics">
<h3>Diagnostics</h3>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="diag:diagnostic">
<table>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="diag:code">
<tr>
<td>
<b>Code:</b>
</td>
<td>
<xsl:value-of select="." />
</td>
</tr>
</xsl:template>
<xsl:template match="diag:message">
<tr>
<td>
<b>Message:</b>
</td>
<td>
<xsl:value-of select="." />
</td>
</tr>
</xsl:template>
<xsl:template match="diag:details">
<tr>
<td>
<b>Details:</b>
</td>
<td>
<xsl:value-of select="." />
</td>
</tr>
</xsl:template>
</xsl:stylesheet>