Add Ubuntu utopic 14.10
[metaproxy-moved-to-github.git] / etc / sru.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:srw="http://www.loc.gov/zing/srw/"
4                 xmlns:dc="http://www.loc.gov/zing/srw/dcschema/v1.0/"
5                 xmlns:zr="http://explain.z3950.org/dtd/2.0/"
6                 xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/"
7                 version="1.0">
8
9   <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
10
11   <xsl:template match="text()"/>
12
13   <xsl:template match="/">
14     <xsl:call-template name="html"/>
15   </xsl:template>
16
17   <xsl:template name="html">
18     <html>
19       <head>
20         <title>
21           <xsl:value-of select="//zr:explain/zr:databaseInfo/zr:title"/>
22         </title>
23         <link href="css.css" rel="stylesheet"
24               type="text/css" media="screen, all"/>
25       </head>
26       <body>
27         <div class="body">
28           <xsl:apply-templates/>
29         </div>
30       </body>
31     </html>
32   </xsl:template>
33
34   <!-- explain -->
35   <xsl:template match="//zr:explain">
36     <xsl:call-template name="dbinfo"/>
37     <xsl:call-template name="diagnostic"/>
38     <xsl:call-template name="indexinfo"/>
39     <xsl:call-template name="relationinfo"/>
40     <xsl:call-template name="searchform"/>
41     <xsl:call-template name="scanform"/>
42   </xsl:template>
43
44
45   <!-- searchRetrieveResponse -->
46   <xsl:template match="//srw:searchRetrieveResponse">
47     <h2>Search Results</h2>
48     <xsl:call-template name="diagnostic"/>
49     <xsl:call-template name="displaysearch"/>
50   </xsl:template>
51
52   <!-- scanResponse -->
53   <xsl:template match="//srw:scanResponse">
54     <h2>Scan Results</h2>
55     <xsl:call-template name="diagnostic"/>
56     <xsl:call-template name="displayscan"/>
57   </xsl:template>
58
59
60   <xsl:template name="dbinfo">
61     <div class="dbinfo">
62       <h1><xsl:value-of select="//zr:explain/zr:databaseInfo/zr:title"/>
63       </h1>
64       <h2><xsl:value-of select="//zr:explain/zr:databaseInfo/zr:description"/>
65       </h2>
66       <h4>
67         <xsl:value-of select="//zr:explain/zr:databaseInfo/zr:author"/>
68         <br/>
69         <xsl:value-of select="//zr:explain/zr:databaseInfo/zr:history"/>
70       </h4>
71     </div>
72   </xsl:template>
73
74
75   <xsl:template name="searchform">
76     <div class="searchform">
77       <form name="searchform"  method="get"> <!-- action=".." -->
78         <input type="hidden" name="version" value="1.1"/>
79         <input type="hidden" name="operation" value="searchRetrieve"/>
80         <div class="query">
81           <input type="text" name="query"/>
82         </div>
83         <div class="parameters">
84           <xsl:text>startRecord: </xsl:text>
85           <input type="text" name="startRecord" value="1"/>
86           <xsl:text> maximumRecords: </xsl:text>
87           <input type="text" name="maximumRecords" value="0"/>
88           <xsl:text> recordSchema: </xsl:text>
89           <select name="recordSchema">
90           <xsl:for-each select="//zr:schemaInfo/zr:schema">
91             <option value="{@name}">
92               <xsl:value-of select="zr:title"/>
93             </option>
94           </xsl:for-each>
95           </select>
96           <xsl:text> recordPacking: </xsl:text>
97           <select name="recordPacking">
98             <option value="string">string</option>
99             <option value="xml">XML</option>
100           </select>
101           <xsl:text> stylesheet: </xsl:text>
102           <select name="stylesheet">
103             <option value="/etc/sru.xsl">SRU</option>
104             <option value="">NONE</option>
105           </select>
106         </div>
107
108         <div class="submit">
109           <input type="submit" value="Send Search Request"/>
110         </div>
111       </form>
112     </div>
113   </xsl:template>
114
115   <xsl:template name="scanform">
116     <div class="scanform">
117       <form name="scanform" method="get"> <!-- action=".." -->
118         <input type="hidden" name="version" value="1.1"/>
119         <input type="hidden" name="operation" value="scan"/>
120         <div class="scanClause">
121           <input type="text" name="scanClause"/>
122         </div>
123         <div class="parameters">
124           <xsl:text>responsePosition: </xsl:text>
125           <input type="text" name="responsePosition" value="1"/>
126           <xsl:text> maximumTerms: </xsl:text>
127           <input type="text" name="maximumTerms" value="15"/>
128           <xsl:text> stylesheet: </xsl:text>
129           <select name="stylesheet">
130             <option value="sru.xsl">SRU</option>
131             <option value="">NONE</option>
132           </select>
133         </div>
134
135         <div class="submit">
136           <input type="submit" value="Send Scan Request"/>
137         </div>
138       </form>
139     </div>
140   </xsl:template>
141
142
143   <xsl:template name="indexinfo">
144      <div class="dbinfo">
145        <xsl:for-each
146           select="//zr:indexInfo/zr:index[zr:map/zr:name/@set]">
147         <xsl:variable name="index">
148           <xsl:value-of select="zr:map/zr:name/@set"/>
149           <xsl:text>.</xsl:text>
150           <xsl:value-of select="zr:map/zr:name/text()"/>
151         </xsl:variable>
152         <b><xsl:value-of select="$index"/><br/></b>
153       </xsl:for-each>
154      </div>
155   </xsl:template>
156
157
158   <xsl:template name="relationinfo">
159     <!--
160       <xsl:variable name="defrel"
161                     select="//zr:configInfo/zr:default[@type='relation']"/>
162       <b><xsl:value-of select="$defrel"/><br/></b>
163       -->
164       <xsl:for-each select="//zr:configInfo/zr:supports[@type='relation']">
165         <xsl:variable name="rel" select="text()"/>
166         <b><xsl:value-of select="$rel"/><br/></b>
167       </xsl:for-each>
168   </xsl:template>
169
170
171   <!-- diagnostics -->
172   <xsl:template name="diagnostic">
173     <xsl:for-each select="//diag:diagnostic">
174      <div class="diagnostic">
175         <!-- <xsl:value-of select="diag:uri"/> -->
176         <xsl:text> </xsl:text>
177         <xsl:value-of select="diag:message"/>
178         <xsl:text>: </xsl:text>
179         <xsl:value-of select="diag:details"/>
180       </div>
181     </xsl:for-each>
182   </xsl:template>
183
184   <xsl:template name="displaysearch">
185     <div class="searchresults">
186       <xsl:for-each select="srw:numberOfRecords">
187         <h4>
188           <xsl:text>Number of Records: </xsl:text>
189           <xsl:value-of select="."/>
190         </h4>
191       </xsl:for-each>
192       <xsl:for-each select="srw:nextRecordPosition">
193         <h4>
194           <xsl:text>Next Record Position: </xsl:text>
195           <xsl:value-of select="."/>
196          </h4>
197       </xsl:for-each>
198
199       <xsl:for-each select="srw:records">
200         <xsl:for-each select="srw:record">
201           <div class="record">
202             <p>
203               <xsl:text>Record: </xsl:text>
204               <xsl:value-of select="srw:recordPosition"/>
205               <xsl:text> : </xsl:text>
206               <xsl:value-of select="srw:recordSchema"/>
207               <xsl:text> : </xsl:text>
208               <xsl:value-of select="srw:recordPacking"/>
209             </p>
210             <p>
211               <pre>
212                 <xsl:value-of select="srw:recordData"/>
213               </pre>
214             </p>
215           </div>
216         </xsl:for-each>
217       </xsl:for-each>
218     </div>
219   </xsl:template>
220
221   <xsl:template name="displayscan">
222     <div class="scanresults">
223
224       <xsl:for-each select="srw:terms">
225         <xsl:for-each select="srw:term">
226           <div class="term">
227
228               <!-- <xsl:text>Term: </xsl:text> -->
229               <xsl:for-each select="srw:displayTerm">
230                 <xsl:value-of select="."/>
231                 <xsl:text> : </xsl:text>
232               </xsl:for-each>
233
234               <xsl:for-each select="srw:value">
235                 <xsl:value-of select="."/>
236               </xsl:for-each>
237
238               <xsl:for-each select="srw:numberOfRecords">
239                 <xsl:text> (</xsl:text>
240                 <xsl:value-of select="."/>
241                 <xsl:text>)</xsl:text>
242               </xsl:for-each>
243
244               <xsl:for-each select="srw:extraTermData">
245                 <xsl:text> - </xsl:text>
246                 <xsl:value-of select="."/>
247               </xsl:for-each>
248
249           </div>
250         </xsl:for-each>
251       </xsl:for-each>
252
253     </div>
254   </xsl:template>
255
256
257 </xsl:stylesheet>