~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/src/site/src/documentation/skins/common/xslt/html/site-to-xhtml.xsl

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0"?>
2
 
<!--
3
 
  Licensed to the Apache Software Foundation (ASF) under one or more
4
 
  contributor license agreements.  See the NOTICE file distributed with
5
 
  this work for additional information regarding copyright ownership.
6
 
  The ASF licenses this file to You under the Apache License, Version 2.0
7
 
  (the "License"); you may not use this file except in compliance with
8
 
  the License.  You may obtain a copy of the License at
9
 
 
10
 
      http://www.apache.org/licenses/LICENSE-2.0
11
 
 
12
 
  Unless required by applicable law or agreed to in writing, software
13
 
  distributed under the License is distributed on an "AS IS" BASIS,
14
 
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 
  See the License for the specific language governing permissions and
16
 
  limitations under the License.
17
 
-->
18
 
<!--
19
 
site-to-xhtml.xsl is the final stage in HTML page production.  It merges HTML from
20
 
document-to-html.xsl, tab-to-menu.xsl and book-to-menu.xsl, and adds the site header,
21
 
footer, searchbar, css etc.  As input, it takes XML of the form:
22
 
 
23
 
<site>
24
 
  <div class="menu">
25
 
    ...
26
 
  </div>
27
 
  <div class="tab">
28
 
    ...
29
 
  </div>
30
 
  <div class="content">
31
 
    ...
32
 
  </div>
33
 
</site>
34
 
 
35
 
-->
36
 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
37
 
  xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java">
38
 
  <xsl:variable name="config" select="//skinconfig"/>
39
 
<!-- If true, a txt link for this page will not be generated -->
40
 
  <xsl:variable name="disable-txt-link" select="//skinconfig/disable-txt-link"/>
41
 
<!-- If true, a PDF link for this page will not be generated -->
42
 
  <xsl:variable name="disable-pdf-link" select="//skinconfig/disable-pdf-link"/>
43
 
<!-- If true, a "print" link for this page will not be generated -->
44
 
  <xsl:variable name="disable-print-link" select="//skinconfig/disable-print-link"/>
45
 
<!-- If true, an XML link for this page will not be generated -->
46
 
  <xsl:variable name="disable-xml-link" select="//skinconfig/disable-xml-link"/>
47
 
<!-- If true, a POD link for this page will not be generated -->
48
 
  <xsl:variable name="disable-pod-link" select="//skinconfig/disable-pod-link"/>
49
 
<!-- Get the location where to generate the minitoc -->
50
 
  <xsl:variable name="minitoc-location" select="//skinconfig/toc/@location"/>
51
 
  <xsl:param name="path"/>
52
 
  <xsl:include href="dotdots.xsl"/>
53
 
  <xsl:include href="pathutils.xsl"/>
54
 
  <xsl:include href="renderlogo.xsl"/>
55
 
<!-- Path (..'s) to the root directory -->
56
 
  <xsl:variable name="root">
57
 
    <xsl:call-template name="dotdots">
58
 
      <xsl:with-param name="path" select="$path"/>
59
 
    </xsl:call-template>
60
 
  </xsl:variable>
61
 
<!-- Source filename (eg 'foo.xml') of current page -->
62
 
  <xsl:variable name="filename">
63
 
    <xsl:call-template name="filename">
64
 
      <xsl:with-param name="path" select="$path"/>
65
 
    </xsl:call-template>
66
 
  </xsl:variable>
67
 
<!-- Path of Lucene search results page (relative to $root) -->
68
 
  <xsl:param name="lucene-search" select="'lucene-search.html'"/>
69
 
  <xsl:variable name="filename-noext">
70
 
    <xsl:call-template name="filename-noext">
71
 
      <xsl:with-param name="path" select="$path"/>
72
 
    </xsl:call-template>
73
 
  </xsl:variable>
74
 
<!-- Whether to obfuscate email links -->
75
 
  <xsl:variable name="obfuscate-mail-links" select="//skinconfig/obfuscate-mail-links"/>
76
 
<!-- If true, the font size script will not be rendered -->
77
 
  <xsl:variable name="disable-font-script" select="//skinconfig/disable-font-script"/>
78
 
<!-- If true, an the images on all external links will not be added -->
79
 
  <xsl:variable name="disable-external-link-image" select="//skinconfig/disable-external-link-image"/>
80
 
  <xsl:variable name="skin-img-dir" select="concat(string($root), 'skin/images')"/>
81
 
  <xsl:variable name="spacer" select="concat($root, 'skin/images/spacer.gif')"/>
82
 
  <xsl:template name="breadcrumbs">
83
 
    <xsl:if test="(//skinconfig/trail/link1/@name)and(//skinconfig/trail/link1/@name!='')"><a href="{//skinconfig/trail/link1/@href}">
84
 
      <xsl:value-of select="//skinconfig/trail/link1/@name"/></a>
85
 
    </xsl:if>
86
 
    <xsl:if test="(//skinconfig/trail/link2/@name)and(//skinconfig/trail/link2/@name!='')"> &gt; <a href="{//skinconfig/trail/link2/@href}">
87
 
      <xsl:value-of select="//skinconfig/trail/link2/@name"/></a>
88
 
    </xsl:if>
89
 
    <xsl:if test="(//skinconfig/trail/link3/@name)and(//skinconfig/trail/link3/@name!='')"> &gt; <a href="{//skinconfig/trail/link3/@href}">
90
 
      <xsl:value-of select="//skinconfig/trail/link3/@name"/></a>
91
 
    </xsl:if>
92
 
<script type="text/javascript" language="JavaScript" src="{$root}skin/breadcrumbs.js"/>
93
 
  </xsl:template>
94
 
  <xsl:template match="site">
95
 
    <html>
96
 
      <head>
97
 
        <title><xsl:value-of select="div[@class='content']/table/tr/td/h1"/></title>
98
 
        <xsl:if test="//skinconfig/favicon-url"><link rel="shortcut icon">
99
 
          <xsl:attribute name="href">
100
 
            <xsl:value-of select="concat($root,//skinconfig/favicon-url)"/>
101
 
          </xsl:attribute></link>
102
 
        </xsl:if>
103
 
      </head>
104
 
      <body>
105
 
        <xsl:if test="//skinconfig/group-url">
106
 
          <xsl:call-template name="renderlogo">
107
 
            <xsl:with-param name="name" select="//skinconfig/group-name"/>
108
 
            <xsl:with-param name="url" select="//skinconfig/group-url"/>
109
 
            <xsl:with-param name="logo" select="//skinconfig/group-logo"/>
110
 
            <xsl:with-param name="root" select="$root"/>
111
 
            <xsl:with-param name="description" select="//skinconfig/group-description"/>
112
 
          </xsl:call-template>
113
 
        </xsl:if>
114
 
        <xsl:call-template name="renderlogo">
115
 
          <xsl:with-param name="name" select="//skinconfig/project-name"/>
116
 
          <xsl:with-param name="url" select="//skinconfig/project-url"/>
117
 
          <xsl:with-param name="logo" select="//skinconfig/project-logo"/>
118
 
          <xsl:with-param name="root" select="$root"/>
119
 
          <xsl:with-param name="description" select="//skinconfig/project-description"/>
120
 
        </xsl:call-template>
121
 
        <xsl:comment>================= start Tabs ==================</xsl:comment>
122
 
        <xsl:apply-templates select="div[@class='tab']"/>
123
 
        <xsl:comment>================= end Tabs ==================</xsl:comment>
124
 
        <xsl:comment>================= start Menu items ==================</xsl:comment>
125
 
        <xsl:apply-templates select="div[@class='menu']"/>
126
 
        <xsl:comment>================= end Menu items ==================</xsl:comment>
127
 
        <xsl:comment>================= start Content==================</xsl:comment>
128
 
        <xsl:apply-templates select="div[@class='content']"/>
129
 
        <xsl:comment>================= end Content==================</xsl:comment>
130
 
        <xsl:comment>================= start Footer ==================</xsl:comment>
131
 
        <xsl:choose>
132
 
          <xsl:when test="$config/copyright-link"><a>
133
 
            <xsl:attribute name="href">
134
 
              <xsl:value-of select="$config/copyright-link"/>
135
 
            </xsl:attribute>
136
 
              Copyright &#169; <xsl:value-of select="$config/year"/>
137
 
            <xsl:call-template name="current-year">
138
 
              <xsl:with-param name="copyrightyear" select="$config/year"/>
139
 
            </xsl:call-template>&#160;
140
 
              <xsl:value-of select="$config/vendor"/></a>
141
 
          </xsl:when>
142
 
          <xsl:otherwise>
143
 
            Copyright &#169; <xsl:value-of select="$config/year"/>
144
 
            <xsl:call-template name="current-year">
145
 
              <xsl:with-param name="copyrightyear" select="$config/year"/>
146
 
            </xsl:call-template>&#160;
147
 
            <xsl:value-of select="$config/vendor"/>
148
 
          </xsl:otherwise>
149
 
        </xsl:choose>
150
 
        All rights reserved.
151
 
        <script language="JavaScript" type="text/javascript"><![CDATA[<!--
152
 
          document.write(" - "+"Last Published: " + document.lastModified);
153
 
          //  -->]]></script>
154
 
        <xsl:if test="//skinconfig/host-logo and not(//skinconfig/host-logo = '')"><a href="{//skinconfig/host-url}">
155
 
          <xsl:call-template name="renderlogo">
156
 
            <xsl:with-param name="name" select="//skinconfig/host-name"/>
157
 
            <xsl:with-param name="url" select="//skinconfig/host-url"/>
158
 
            <xsl:with-param name="logo" select="//skinconfig/host-logo"/>
159
 
            <xsl:with-param name="root" select="$root"/>
160
 
          </xsl:call-template></a>
161
 
        </xsl:if>
162
 
        <xsl:if test="$filename = 'index.html' and //skinconfig/credits">
163
 
          <xsl:for-each select="//skinconfig/credits/credit[not(@role='pdf')]">
164
 
            <xsl:call-template name="renderlogo">
165
 
              <xsl:with-param name="name" select="name"/>
166
 
              <xsl:with-param name="url" select="url"/>
167
 
              <xsl:with-param name="logo" select="image"/>
168
 
              <xsl:with-param name="root" select="$root"/>
169
 
              <xsl:with-param name="width" select="width"/>
170
 
              <xsl:with-param name="height" select="height"/>
171
 
            </xsl:call-template>
172
 
          </xsl:for-each>
173
 
        </xsl:if><a href="http://validator.w3.org/check/referer">
174
 
        <img class="skin" border="0"
175
 
            src="http://www.w3.org/Icons/valid-html401"
176
 
            alt="Valid HTML 4.01!" height="31" width="88"/></a>
177
 
      </body>
178
 
    </html>
179
 
  </xsl:template>
180
 
<!-- Add links to any standards-compliance logos -->
181
 
  <xsl:template name="compliancy-logos">
182
 
    <xsl:if test="$filename = 'index.html' and //skinconfig/disable-compliance-links = 'false'"><a href="http://validator.w3.org/check/referer">
183
 
      <img class="logoImage"
184
 
          src="{$skin-img-dir}/valid-html401.png"
185
 
          alt="Valid HTML 4.01!" title="Valid HTML 4.01!" height="31" width="88" border="0"/></a><a href="http://jigsaw.w3.org/css-validator/check/referer">
186
 
      <img class="logoImage"
187
 
          src="{$skin-img-dir}/vcss.png"
188
 
          alt="Valid CSS!" title="Valid CSS!" height="31" width="88" border="0"/></a>
189
 
    </xsl:if>
190
 
  </xsl:template>
191
 
<!-- Generates the PDF link -->
192
 
  <xsl:template match="div[@id='skinconf-pdflink']">
193
 
    <xsl:if test="not($config/disable-pdf-link) or $disable-pdf-link = 'false'">
194
 
      <td align="center" width="40" nowrap="nowrap"><a href="{$filename-noext}.pdf" class="dida">
195
 
        <img class="skin" src="{$skin-img-dir}/pdfdoc.gif" alt="PDF"/>
196
 
        <br/>
197
 
        PDF</a>
198
 
      </td>
199
 
    </xsl:if>
200
 
  </xsl:template>
201
 
<!-- Generates the TXT link -->
202
 
  <xsl:template match="div[@id='skinconf-txtlink']">
203
 
    <xsl:if test="$disable-txt-link = 'false'">
204
 
      <td align="center" width="40" nowrap="nowrap"><a href="{$filename-noext}.txt" class="dida">
205
 
        <img class="skin" src="{$skin-img-dir}/txtdoc.png" alt="TXT"/>
206
 
        <br/>
207
 
        TXT</a>
208
 
      </td>
209
 
    </xsl:if>
210
 
  </xsl:template>
211
 
<!-- Generates the POD link -->
212
 
  <xsl:template match="div[@id='skinconf-podlink']">
213
 
    <xsl:if test="$disable-pod-link = 'false'">
214
 
      <td align="center" width="40" nowrap="nowrap"><a href="{$filename-noext}.pod" class="dida">
215
 
        <img class="skin" src="{$skin-img-dir}/poddoc.png" alt="POD"/>
216
 
        <br/>
217
 
        POD</a>
218
 
      </td>
219
 
    </xsl:if>
220
 
  </xsl:template>
221
 
<!-- Generates the XML link -->
222
 
  <xsl:template match="div[@id='skinconf-xmllink']">
223
 
    <xsl:if test="$disable-xml-link = 'false'">
224
 
      <td align="center" width="40" nowrap="nowrap"><a href="{$filename-noext}.xml" class="dida">
225
 
        <img class="skin" src="{$skin-img-dir}/xmldoc.gif" alt="XML"/>
226
 
        <br/>
227
 
        XML</a>
228
 
      </td>
229
 
    </xsl:if>
230
 
  </xsl:template>
231
 
<!-- Generates the "printer friendly version" link -->
232
 
  <xsl:template match="div[@id='skinconf-printlink']">
233
 
    <xsl:if test="$disable-print-link = 'false'">
234
 
<script type="text/javascript" language="Javascript">
235
 
function printit() {
236
 
  if (window.print) {
237
 
    window.focus();
238
 
    window.print();
239
 
  }
240
 
}
241
 
 
242
 
var NS = (navigator.appName == "Netscape");
243
 
var VERSION = parseInt(navigator.appVersion);
244
 
if (VERSION > 3) {
245
 
    document.write('<td align="center" width="40" nowrap="nowrap">');
246
 
    document.write('  <a href="javascript:printit()" class="dida">');
247
 
    document.write('    <img class="skin" src="{$skin-img-dir}/printer.gif" alt="Print this Page"/><br />');
248
 
    document.write('  print</a>');
249
 
    document.write('</td>');
250
 
}
251
 
</script>
252
 
    </xsl:if>
253
 
  </xsl:template>
254
 
<!-- handle all obfuscating mail links and disabling external link images -->
255
 
  <xsl:template match="a">
256
 
    <xsl:choose>
257
 
      <xsl:when test="$obfuscate-mail-links='true' and starts-with(@href, 'mailto:') and contains(@href, '@')">
258
 
        <xsl:variable name="mailto-1" select="substring-before(@href,'@')"/>
259
 
        <xsl:variable name="mailto-2" select="substring-after(@href,'@')"/>
260
 
        <xsl:variable name="obfuscation" select="normalize-space(//skinconfig/obfuscate-mail-value)"/><a href="{$mailto-1}{$obfuscation}{$mailto-2}">
261
 
        <xsl:apply-templates/></a>
262
 
      </xsl:when>
263
 
      <xsl:when test="not($disable-external-link-image='true') and contains(@href, ':') and not(contains(@href, //skinconfig/group-url)) and not(contains(@href, //skinconfig/project-url))"><a href="{@href}" class="external">
264
 
        <xsl:apply-templates/></a>
265
 
      </xsl:when>
266
 
      <xsl:otherwise>
267
 
<!-- xsl:copy-of makes sure we copy <a href> as well as <a name>
268
 
             or any other <a ...> forms -->
269
 
        <xsl:copy-of select="."/>
270
 
      </xsl:otherwise>
271
 
    </xsl:choose>
272
 
  </xsl:template>
273
 
  <xsl:template match="div[@id='skinconf-toc-page']">
274
 
    <xsl:if test="$config/toc">
275
 
      <xsl:if test="contains($minitoc-location,'page')">
276
 
        <xsl:if test="(count(//tocitems/tocitem) >= $config/toc/@min-sections) or (//tocitems/@force = 'true')">
277
 
          <xsl:call-template name="minitoc">
278
 
            <xsl:with-param name="tocroot" select="//tocitems"/>
279
 
          </xsl:call-template>
280
 
        </xsl:if>
281
 
      </xsl:if>
282
 
    </xsl:if>
283
 
  </xsl:template>
284
 
  <xsl:template name="minitoc">
285
 
    <xsl:param name="tocroot"/>
286
 
    <xsl:if test="(count($tocroot/tocitem) >= $config/toc/@min-sections) or ($tocroot/@force = 'true')">
287
 
      <xsl:if test="contains($config/toc/@location,'page')">
288
 
        <ul class="minitoc">
289
 
          <xsl:for-each select="$tocroot/tocitem">
290
 
            <li><a href="{@href}">
291
 
              <xsl:value-of select="@title"/></a>
292
 
              <xsl:if test="@level&lt;//skinconfig/toc/@max-depth+1">
293
 
                <xsl:call-template name="minitoc">
294
 
                  <xsl:with-param name="tocroot" select="."/>
295
 
                </xsl:call-template>
296
 
              </xsl:if></li>
297
 
          </xsl:for-each>
298
 
        </ul>
299
 
      </xsl:if>
300
 
    </xsl:if>
301
 
  </xsl:template>
302
 
  <xsl:template name="html-meta">
303
 
    <meta name="Generator" content="Apache Forrest"/>
304
 
    <meta name="Forrest-version">
305
 
      <xsl:attribute name="content">
306
 
        <xsl:value-of select="//info/forrest-version"/>
307
 
      </xsl:attribute>
308
 
    </meta>
309
 
    <meta name="Forrest-skin-name">
310
 
      <xsl:attribute name="content">
311
 
        <xsl:value-of select="//info/project-skin"/>
312
 
      </xsl:attribute>
313
 
    </meta>
314
 
  </xsl:template>
315
 
<!-- meta information from v 2.0 documents
316
 
       FIXME: the match is really inefficient -->
317
 
  <xsl:template name="meta-data">
318
 
    <xsl:for-each select="//meta-data/meta">
319
 
      <xsl:element name="meta">
320
 
        <xsl:attribute name="name">
321
 
          <xsl:value-of select="@name"/>
322
 
        </xsl:attribute>
323
 
        <xsl:attribute name="content">
324
 
          <xsl:value-of select="."/>
325
 
        </xsl:attribute>
326
 
        <xsl:if test="@xml:lang">
327
 
          <xsl:attribute name="lang">
328
 
            <xsl:value-of select="@xml:lang"/>
329
 
          </xsl:attribute>
330
 
        </xsl:if>
331
 
      </xsl:element>
332
 
    </xsl:for-each>
333
 
  </xsl:template>
334
 
  <xsl:template name="feedback">
335
 
    <div id="feedback">
336
 
      <xsl:value-of select="$config/feedback"/>
337
 
      <xsl:choose>
338
 
        <xsl:when test="$config/feedback/@href and not($config/feedback/@href='')"><a id="feedbackto">
339
 
          <xsl:attribute name="href">
340
 
            <xsl:value-of select="$config/feedback/@href"/>
341
 
            <xsl:value-of select="$path"/>
342
 
          </xsl:attribute>
343
 
          <xsl:value-of select="$config/feedback/@to"/></a>
344
 
        </xsl:when>
345
 
        <xsl:otherwise>
346
 
          <xsl:value-of select="$config/feedback/@to"/>
347
 
        </xsl:otherwise>
348
 
      </xsl:choose>
349
 
    </div>
350
 
  </xsl:template>
351
 
  <xsl:template match="node()|@*" priority="-1">
352
 
    <xsl:copy>
353
 
      <xsl:apply-templates select="@*"/>
354
 
      <xsl:apply-templates/>
355
 
    </xsl:copy>
356
 
  </xsl:template>
357
 
<!-- inception year copyright management -->
358
 
  <xsl:template name="current-year">
359
 
<!-- Displays the current year after the inception year (in the copyright i.e: 2002-2005)
360
 
       - the copyright year (2005 by default) can be indicated in the copyrightyear parameter,
361
 
       - the year format (yyyy by default) can be indicated in the dateformat parameter,
362
 
       - the dates separator (- by default) can be indicated in the dateseparator parameter.
363
 
       For instance the following call will format the year on 2 digits and separates the dates
364
 
       with /
365
 
       (copyright 02/05)
366
 
        <xsl:call-template name="current-year">
367
 
           <xsl:with-param name="copyrightyear" select="'02'"/>
368
 
           <xsl:with-param name="dateformat" select="'yy'"/>
369
 
           <xsl:with-param name="dateseparator" select="'/'"/>
370
 
         </xsl:call-template>
371
 
       Warning, to enable inception year, inception attribute must be set to "true" in copyright/year/@inception
372
 
     -->
373
 
    <xsl:param name="copyrightyear">2005</xsl:param>
374
 
    <xsl:param name="dateformat">yyyy</xsl:param>
375
 
    <xsl:param name="dateseparator">-</xsl:param>
376
 
    <xsl:if test="$copyrightyear[@inception = 'true']">
377
 
      <xsl:variable name="tz" select='java:java.util.SimpleTimeZone.new(0,"GMT+00:00")' />
378
 
      <xsl:variable name="formatter" select="java:java.text.SimpleDateFormat.new($dateformat)"/>
379
 
      <xsl:variable name="settz" select="java:setTimeZone($formatter, $tz)" />
380
 
      <xsl:variable name="date" select="java:java.util.Date.new()"/>
381
 
      <xsl:variable name="year" select="java:format($formatter, $date)"/>
382
 
      <xsl:if test="$copyrightyear != $year">
383
 
        <xsl:value-of select="$dateseparator"/>
384
 
        <xsl:value-of select="$year"/>
385
 
      </xsl:if>
386
 
    </xsl:if>
387
 
  </xsl:template>
388
 
</xsl:stylesheet>