source: main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl@ 24243

Last change on this file since 24243 was 24243, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

File size: 13.5 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util gsf">
10
11 <!-- use the 'main' layout -->
12 <xsl:import href="layouts/main.xsl"/>
13
14 <!-- style includes global params interface_name, library_name -->
15 <xsl:include href=".old/berrytools.xsl"/>
16 <xsl:include href="document-scripts.xsl"/>
17
18 <xsl:variable name="bookswitch">
19 <xsl:choose>
20 <xsl:when test="/page/pageRequest/paramList/param[@name='book']/@value">
21 <xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
22 </xsl:when>
23 <xsl:otherwise>off</xsl:otherwise>
24 </xsl:choose>
25 </xsl:variable>
26
27 <!-- set page title -->
28 <xsl:template name="pageTitle"><gslib:documentTitle/></xsl:template>
29
30 <!-- set page breadcrumbs -->
31 <xsl:template name="breadcrumbs">
32 <gslib:siteLink/><gslib:rightArrow/>
33 <gslib:collectionNameLinked/><gslib:rightArrow/>
34 <a>
35 <xsl:attribute name="href">
36 <xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="$collName"/>&amp;d=<xsl:value-of select="/page/pageResponse/document/documentNode[1]/@nodeID"/>&amp;dt=<xsl:value-of select="/page/pageResponse/document/documentNode/@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>
37 </xsl:attribute>
38 <xsl:variable name="documentTitleVar">
39 <gslib:documentTitle/>
40 </xsl:variable>
41 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.document')"/>
42 </a>
43 </xsl:template>
44
45 <xsl:template match="/">
46 <xsl:choose>
47 <!-- if this is the realistic books version of the page -->
48 <xsl:when test="$bookswitch = 'flashxml'">
49 <html>
50 <body>
51 <xsl:apply-templates select="/page/pageResponse/document"/>
52 </body>
53 </html>
54 </xsl:when>
55 <!-- if this is the regular version of the page -->
56 <xsl:otherwise>
57 <xsl:apply-imports/>
58 </xsl:otherwise>
59 </xsl:choose>
60 </xsl:template>
61
62 <!-- the page content -->
63 <xsl:template match="/page/pageResponse/document">
64 <xsl:if test="$bookswitch = 'off'">
65 <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
66
67 <!-- Adds the realistic books javascript if necessary ( *** in document-scripts.xsl *** ) -->
68 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
69 <xsl:call-template name="realisticBooksScript"/>
70 </xsl:if>
71
72 <!-- Add the Javascript that adds and removes highlighting ( *** in document-scripts.xsl *** ) -->
73 <xsl:call-template name="highlightingScript"/>
74
75 <!-- Add the Javascript that expands and collapses sections ( *** in document-scripts.xsl *** ) -->
76 <xsl:call-template name="expansionScript"/>
77
78 <!-- show the little berries for this document -->
79 <xsl:call-template name="documentBerryForDocumentPage"/>
80
81 <table id="rightSidebar">
82 <tr><td>
83 <xsl:call-template name="viewOptions"/>
84 </td></tr>
85 <tr><td>
86 <!-- the sidebar -->
87 <div id="contentsArea">
88 <!-- show the berry basket if it's turned on -->
89 <gslib:berryBasket/>
90
91 <!-- the book's cover image -->
92 <xsl:choose>
93 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
94 <div id="coverImage" class="visible"><gslib:coverImage/></div>
95 </xsl:when>
96 <xsl:otherwise>
97 <div id="coverImage" class="hidden"><gslib:coverImage/></div>
98 </xsl:otherwise>
99 </xsl:choose>
100
101 <!-- the contents (if enabled) -->
102 <xsl:choose>
103 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
104 <div id="tableOfContents" class="visible">
105 <xsl:apply-templates select="documentNode" mode="TOC"/>
106 </div>
107 </xsl:when>
108 <xsl:otherwise>
109 <div id="tableOfContents" class="hidden">
110 <xsl:apply-templates select="documentNode" mode="TOC"/>
111 </div>
112 </xsl:otherwise>
113 </xsl:choose>
114 </div>
115 </td></tr>
116 </table>
117 </xsl:if>
118
119 <!-- display the document -->
120 <xsl:choose>
121 <xsl:when test="@external != ''">
122 <xsl:call-template name="externalPage">
123 <xsl:with-param name="external" select="@external"/>
124 </xsl:call-template>
125 </xsl:when>
126 <xsl:when test="$bookswitch = 'flashxml'">
127 <xsl:apply-templates mode="flashxml"/>
128 </xsl:when>
129 <xsl:when test="$bookswitch = 'on'">
130 <!-- *** in document-scripts.xsl *** -->
131 <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
132 <xsl:call-template name="realisticBooksScript"/>
133 </xsl:when>
134 <xsl:otherwise>
135 <div id="gs-document-text" class="documenttext">
136 <xsl:apply-templates select="documentNode" mode="document"/>
137 </div>
138 </xsl:otherwise>
139 </xsl:choose>
140
141 <div class="clear"><xsl:text> </xsl:text></div>
142 </xsl:template>
143
144 <!-- Highlight annotations if requested -->
145 <xsl:template match="annotation">
146 <xsl:choose>
147 <xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
148 <span class="termHighlight"><xsl:value-of select="."/></span>
149 </xsl:when>
150 <xsl:otherwise>
151 <span class="noTermHighlight"><xsl:value-of select="."/></span>
152 </xsl:otherwise>
153 </xsl:choose>
154 </xsl:template>
155
156 <!-- This template is used to display the document content -->
157 <xsl:template match="documentNode" mode="document">
158 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
159 <!-- Section header -->
160 <table class="sectionHeader"><tr>
161 <!-- Expand/collapse button -->
162 <td class="headerTD">
163 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
164 <xsl:attribute name="src">
165 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
166 </xsl:attribute>
167 </img>
168 </td>
169
170 <!-- Automatic section number -->
171 <td class="headerTD">
172 <p>
173 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
174
175 <xsl:if test="util:hashToSectionId(@nodeID)">
176 <span class="sectionNumberSpan">
177 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
178 <xsl:text> </xsl:text>
179 </span>
180 </xsl:if>
181 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
182 <span class="sectionTitle"><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/></span>
183 </p>
184 </td>
185
186 <!-- "back to top" link -->
187 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
188 <td class="backToTop headerTD">
189 <a href="#top">
190 <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
191 </a>
192 </td>
193 </xsl:if>
194 </tr></table>
195
196 <!-- Section text -->
197 <div id="doc{@nodeID}" class="sectionContainer" style="display:block;">
198 <xsl:for-each select="nodeContent">
199 <xsl:for-each select="node()">
200 <xsl:choose>
201 <xsl:when test="not(name())">
202 <xsl:value-of select="." disable-output-escaping="yes"/>
203 </xsl:when>
204 <xsl:otherwise>
205 <xsl:apply-templates select="."/>
206 </xsl:otherwise>
207 </xsl:choose>
208 </xsl:for-each>
209 </xsl:for-each>
210 <xsl:if test="documentNode">
211 <xsl:apply-templates select="documentNode" mode="document"/>
212 </xsl:if>
213 </div>
214
215 </xsl:template>
216
217 <!-- This template is used to display the table of contents -->
218 <xsl:template match="documentNode" mode="TOC">
219
220 <!-- check if this is the currently selected table of contents item -->
221 <xsl:variable name="isCurrent" select="nodeContent"/>
222
223 <!-- formulate the link -->
224 <xsl:variable name="contentsLink">
225 <xsl:value-of select='$library_name'/>?a=d&amp;c=<gslib:collectionNameShort/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if>&amp;sib=1
226 </xsl:variable>
227
228 <ul>
229 <table><tr>
230 <!-- The expand/collapse button (not displayed for the top level node) -->
231 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
232 <td>
233 <xsl:choose>
234 <xsl:when test="not(nodeContent and not(documentNode))">
235 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
236 <xsl:attribute name="src">
237 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
238 </xsl:attribute>
239 </img>
240 </xsl:when>
241 <xsl:otherwise>
242 <xsl:attribute name="class">emptyIcon</xsl:attribute>
243 </xsl:otherwise>
244 </xsl:choose>
245 </td>
246 </xsl:if>
247
248 <!-- The chapter/page icon -->
249 <td>
250 <img>
251 <xsl:if test="nodeContent and not(documentNode)">
252 <xsl:attribute name="class">leafNode</xsl:attribute>
253 </xsl:if>
254
255 <xsl:attribute name="src">
256 <xsl:choose>
257 <xsl:when test="nodeContent and not(documentNode)">
258 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
259 </xsl:when>
260 <xsl:otherwise>
261 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
262 </xsl:otherwise>
263 </xsl:choose>
264 </xsl:attribute>
265 </img>
266 </td>
267
268 <!-- The section name, links to the section in the document -->
269 <td>
270 <a>
271 <xsl:attribute name="href">#<xsl:value-of select="@nodeID"/></xsl:attribute>
272 <xsl:if test="util:hashToSectionId(@nodeID)">
273 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
274 <xsl:text> </xsl:text>
275 </xsl:if>
276 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
277 </a>
278 </td>
279 </tr></table>
280
281 <!-- display any child items -->
282 <xsl:if test="documentNode">
283 <li id="toc{@nodeID}" style="display:block;">
284 <xsl:apply-templates select="documentNode" mode="TOC"/>
285 </li>
286 </xsl:if>
287
288 </ul>
289 </xsl:template>
290
291 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
292 <xsl:template match="documentNode" mode="flashxml">
293 <xsl:text disable-output-escaping="yes">
294 &lt;Section&gt;
295 &lt;Description&gt;
296 &lt;Metadata name="Title"&gt;
297 </xsl:text>
298 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
299 <xsl:text disable-output-escaping="yes">
300 &lt;/Metadata&gt;
301 &lt;/Description&gt;
302 </xsl:text>
303
304 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
305
306 <xsl:if test="documentNode">
307 <xsl:apply-templates select="documentNode" mode="flashxml"/>
308 </xsl:if>
309
310 <xsl:text disable-output-escaping="yes">
311 &lt;/Section&gt;
312 </xsl:text>
313 </xsl:template>
314
315 <xsl:template name="externalPage">
316 <xsl:param name="external"/>
317 <xsl:variable name="go_forward_link">
318 <a>
319 <xsl:attribute name="href">
320 <xsl:value-of select="$external"/>
321 </xsl:attribute>
322 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
323 </a>
324 </xsl:variable>
325 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
326 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
327 </xsl:template>
328
329 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
330
331 <xsl:template name="viewOptions">
332 <table class="viewOptions"><tr>
333 <!-- Realistic books link -->
334 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
335 <td>
336 <img>
337 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
338 </img>
339 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
340 </td>
341 </xsl:if>
342
343 <!-- Highlight on/off button -->
344 <xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q' and count(//annotation) > 0">
345 <td>
346 <img>
347 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
348 </img>
349 <input id="highlightOption" type="checkbox" class="optionCheckBox">
350 <xsl:choose>
351 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
352 <xsl:attribute name="onclick">
353 <xsl:text>removeHighlight();</xsl:text>
354 </xsl:attribute>
355 <xsl:attribute name="checked">true</xsl:attribute>
356 </xsl:when>
357 <xsl:otherwise>
358 <xsl:attribute name="onclick">
359 <xsl:text>addHighlight();</xsl:text>
360 </xsl:attribute>
361 </xsl:otherwise>
362 </xsl:choose>
363 </input>
364 </td>
365 </xsl:if>
366 </tr></table>
367 </xsl:template>
368</xsl:stylesheet>
369
Note: See TracBrowser for help on using the repository browser.