1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                version="1.0">
4
5<xsl:template match="head" mode="head.mode">
6  <xsl:variable name="nodes" select="*"/>
7  <head>
8    <meta name="generator" content="Website XSL Stylesheet V{$VERSION}"/>
9    <xsl:if test="$html.stylesheet != ''">
10      <link rel="stylesheet" href="{$html.stylesheet}" type="text/css">
11	<xsl:if test="$html.stylesheet.type != ''">
12	  <xsl:attribute name="type">
13	    <xsl:value-of select="$html.stylesheet.type"/>
14	  </xsl:attribute>
15	</xsl:if>
16      </link>
17    </xsl:if>
18
19    <xsl:variable name="thisid" select="ancestor-or-self::webpage/@id"/>
20    <xsl:variable name="thisrelpath">
21      <xsl:apply-templates select="$autolayout//*[@id=$thisid]" mode="toc-rel-path"/>
22    </xsl:variable>
23
24    <xsl:variable name="topid">
25      <xsl:call-template name="top.page"/>
26    </xsl:variable>
27
28    <xsl:if test="$topid != ''">
29      <link rel="home">
30        <xsl:attribute name="href">
31          <xsl:call-template name="page.uri">
32            <xsl:with-param name="page" select="$autolayout//*[@id=$topid]"/>
33            <xsl:with-param name="relpath" select="$thisrelpath"/>
34          </xsl:call-template>
35        </xsl:attribute>
36        <xsl:attribute name="title">
37          <xsl:value-of select="$autolayout//*[@id=$topid]/title"/>
38        </xsl:attribute>
39      </link>
40    </xsl:if>
41
42    <xsl:variable name="upid">
43      <xsl:call-template name="up.page"/>
44    </xsl:variable>
45
46    <xsl:if test="$upid != ''">
47      <link rel="up">
48        <xsl:attribute name="href">
49          <xsl:call-template name="page.uri">
50            <xsl:with-param name="page" select="$autolayout//*[@id=$upid]"/>
51            <xsl:with-param name="relpath" select="$thisrelpath"/>
52          </xsl:call-template>
53        </xsl:attribute>
54        <xsl:attribute name="title">
55          <xsl:value-of select="$autolayout//*[@id=$upid]/title"/>
56        </xsl:attribute>
57      </link>
58    </xsl:if>
59
60    <xsl:variable name="previd">
61      <xsl:call-template name="prev.page"/>
62    </xsl:variable>
63
64    <xsl:if test="$previd != ''">
65      <link rel="previous">
66        <xsl:attribute name="href">
67          <xsl:call-template name="page.uri">
68            <xsl:with-param name="page" select="$autolayout//*[@id=$previd]"/>
69            <xsl:with-param name="relpath" select="$thisrelpath"/>
70          </xsl:call-template>
71        </xsl:attribute>
72        <xsl:attribute name="title">
73          <xsl:value-of select="$autolayout//*[@id=$previd]/title"/>
74        </xsl:attribute>
75      </link>
76    </xsl:if>
77
78    <xsl:variable name="nextid">
79      <xsl:call-template name="next.page"/>
80    </xsl:variable>
81
82    <xsl:if test="$nextid != ''">
83      <link rel="next">
84        <xsl:attribute name="href">
85          <xsl:call-template name="page.uri">
86            <xsl:with-param name="page" select="$autolayout//*[@id=$nextid]"/>
87            <xsl:with-param name="relpath" select="$thisrelpath"/>
88          </xsl:call-template>
89        </xsl:attribute>
90        <xsl:attribute name="title">
91          <xsl:value-of select="$autolayout//*[@id=$nextid]/title"/>
92        </xsl:attribute>
93      </link>
94    </xsl:if>
95
96    <xsl:variable name="firstid">
97      <xsl:call-template name="first.page"/>
98    </xsl:variable>
99
100    <xsl:if test="$firstid != ''">
101      <link rel="first">
102        <xsl:attribute name="href">
103          <xsl:call-template name="page.uri">
104            <xsl:with-param name="page" select="$autolayout//*[@id=$firstid]"/>
105            <xsl:with-param name="relpath" select="$thisrelpath"/>
106          </xsl:call-template>
107        </xsl:attribute>
108        <xsl:attribute name="title">
109          <xsl:value-of select="$autolayout//*[@id=$firstid]/title"/>
110        </xsl:attribute>
111      </link>
112    </xsl:if>
113
114    <xsl:variable name="lastid">
115      <xsl:call-template name="last.page"/>
116    </xsl:variable>
117
118    <xsl:if test="$lastid != ''">
119      <link rel="last">
120        <xsl:attribute name="href">
121          <xsl:call-template name="page.uri">
122            <xsl:with-param name="page" select="$autolayout//*[@id=$lastid]"/>
123            <xsl:with-param name="relpath" select="$thisrelpath"/>
124          </xsl:call-template>
125        </xsl:attribute>
126        <xsl:attribute name="title">
127          <xsl:value-of select="$autolayout//*[@id=$lastid]/title"/>
128        </xsl:attribute>
129      </link>
130    </xsl:if>
131
132    <xsl:apply-templates select="$autolayout/autolayout/style
133                                 |$autolayout/autolayout/script
134                                 |$autolayout/autolayout/headlink"
135                         mode="head.mode">
136      <xsl:with-param name="webpage" select="ancestor::webpage"/>
137    </xsl:apply-templates>
138    <xsl:apply-templates mode="head.mode"/>
139    <xsl:call-template name="user.head.content">
140      <xsl:with-param name="node" select="ancestor::webpage"/>
141    </xsl:call-template>
142  </head>
143</xsl:template>
144
145<xsl:template match="title" mode="head.mode">
146  <title><xsl:value-of select="."/></title>
147</xsl:template>
148
149<xsl:template match="titleabbrev" mode="head.mode">
150  <!--nop-->
151</xsl:template>
152
153<xsl:template match="subtitle" mode="head.mode">
154  <!--nop-->
155</xsl:template>
156
157<xsl:template match="summary" mode="head.mode">
158  <!--nop-->
159</xsl:template>
160
161<xsl:template match="base" mode="head.mode">
162  <base href="{@href}">
163    <xsl:if test="@target">
164      <xsl:attribute name="target">
165        <xsl:value-of select="@target"/>
166      </xsl:attribute>
167    </xsl:if>
168  </base>
169</xsl:template>
170
171<xsl:template match="keywords" mode="head.mode">
172  <meta name="keyword" content="{.}"/>
173  <meta name="keywords" content="{.}"/>
174</xsl:template>
175
176<xsl:template match="copyright" mode="head.mode">
177  <!--nop-->
178</xsl:template>
179
180<xsl:template match="author" mode="head.mode">
181  <!--nop-->
182</xsl:template>
183
184<xsl:template match="edition" mode="head.mode">
185  <!--nop-->
186</xsl:template>
187
188<xsl:template match="meta" mode="head.mode">
189  <xsl:choose>
190    <xsl:when test="@http-equiv">
191      <meta http-equiv="{@http-equiv}" content="{@content}"/>
192    </xsl:when>
193    <xsl:otherwise>
194      <meta name="{@name}" content="{@content}"/>
195    </xsl:otherwise>
196  </xsl:choose>
197</xsl:template>
198
199<xsl:template match="script" mode="head.mode">
200  <script>
201    <xsl:choose>
202      <xsl:when test="@language">
203	<xsl:attribute name="language">
204	  <xsl:value-of select="@language"/>
205	</xsl:attribute>
206      </xsl:when>
207      <xsl:otherwise>
208	<xsl:attribute name="language">JavaScript</xsl:attribute>
209      </xsl:otherwise>
210    </xsl:choose>
211    <xsl:choose>
212      <xsl:when test="@type">
213	<xsl:attribute name="type">
214	  <xsl:value-of select="@type"/>
215	</xsl:attribute>
216      </xsl:when>
217      <xsl:otherwise>
218	<xsl:attribute name="type">text/javascript</xsl:attribute>
219      </xsl:otherwise>
220    </xsl:choose>
221    <xsl:apply-templates/>
222  </script>
223</xsl:template>
224
225<xsl:template match="script[@src]" mode="head.mode" priority="2">
226  <xsl:param name="webpage" select="ancestor::webpage"/>
227  <xsl:variable name="relpath">
228    <xsl:call-template name="root-rel-path">
229      <xsl:with-param name="webpage" select="$webpage"/>
230    </xsl:call-template>
231  </xsl:variable>
232
233  <xsl:variable name="language">
234    <xsl:choose>
235      <xsl:when test="@language">
236	<xsl:value-of select="@language"/>
237      </xsl:when>
238      <xsl:otherwise>JavaScript</xsl:otherwise>
239    </xsl:choose>
240  </xsl:variable>
241
242  <xsl:variable name="type">
243    <xsl:choose>
244      <xsl:when test="@type">
245	<xsl:value-of select="@type"/>
246      </xsl:when>
247      <xsl:otherwise>text/javascript</xsl:otherwise>
248    </xsl:choose>
249  </xsl:variable>
250
251  <script src="{$relpath}{@src}" language="{$language}" type="{$type}"/>
252</xsl:template>
253
254<xsl:template match="style" mode="head.mode">
255  <style>
256    <xsl:if test="@type">
257      <xsl:attribute name="type">
258	<xsl:value-of select="@type"/>
259      </xsl:attribute>
260    </xsl:if>
261
262    <xsl:apply-templates/>
263
264  </style>
265</xsl:template>
266
267<xsl:template match="style[@src]" mode="head.mode" priority="2">
268  <xsl:param name="webpage" select="ancestor::webpage"/>
269  <xsl:variable name="relpath">
270    <xsl:call-template name="root-rel-path">
271      <xsl:with-param name="webpage" select="$webpage"/>
272    </xsl:call-template>
273  </xsl:variable>
274
275  <xsl:choose>
276    <xsl:when test="starts-with(@src, '/')">
277      <link rel="stylesheet" href="{@src}">
278        <xsl:if test="@type">
279          <xsl:attribute name="type">
280            <xsl:value-of select="@type"/>
281          </xsl:attribute>
282        </xsl:if>
283      </link>
284    </xsl:when>
285    <xsl:otherwise>
286      <link rel="stylesheet" href="{$relpath}{@src}">
287        <xsl:if test="@type">
288          <xsl:attribute name="type">
289            <xsl:value-of select="@type"/>
290          </xsl:attribute>
291        </xsl:if>
292      </link>
293    </xsl:otherwise>
294  </xsl:choose>
295</xsl:template>
296
297<xsl:template match="headlink" mode="head.mode">
298  <link>
299    <xsl:copy-of select="@*"/>
300  </link>
301</xsl:template>
302
303<xsl:template match="abstract" mode="head.mode">
304  <!--nop-->
305</xsl:template>
306
307<xsl:template match="revhistory" mode="head.mode">
308  <!--nop-->
309</xsl:template>
310
311<xsl:template match="rddl:*" mode="head.mode"
312              xmlns:rddl='http://www.rddl.org/'>
313  <!--nop-->
314</xsl:template>
315
316</xsl:stylesheet>
317