source: trunk/gsdl3/web/interfaces/classic/transform/document.xsl@ 13261

Last change on this file since 13261 was 13261, checked in by shaoqun, 15 years ago

the classic interface uses the icons of the default interface to prevent duplicate stock of icons

  • Property svn:keywords set to Author Date Id Revision
File size: 19.3 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:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
7 extension-element-prefixes="java util"
8 exclude-result-prefixes="java util gsf">
9
10 <xsl:include href="style.xsl"/>
11 <xsl:include href="service-params.xsl"/>
12 <xsl:output method="html"/>
13
14 <!-- the main page layout template is here -->
15 <!-- override the one in style so we can display the doc over the whole page and get rid of the green bar down the side -->
16 <xsl:template match="page" priority='2'>
17 <html>
18 <xsl:call-template name="pageHead"/>
19 <body>
20 <div id="page">
21 <xsl:apply-templates select="pageResponse"/>
22 <xsl:call-template name="greenstoneFooter"/>
23 </div>
24 </body>
25 </html>
26 </xsl:template>
27
28 <xsl:template name="pageTitle">
29 <xsl:variable name="docID" select="/page/pageResponse/document/@selectedNode"/>
30 <xsl:for-each select='/page/pageResponse/document/descendant::documentNode[@nodeID=$docID]/ancestor-or-self::documentNode'><xsl:if test='position()!=1'>::</xsl:if><xsl:value-of select="metadataList/metadata[@name='Title']"/></xsl:for-each>
31 </xsl:template>
32
33 <!-- this is hard coded for GATE, should somehow do it dynamically-->
34 <xsl:template name="pageStyle">
35 <style type="text/css">
36 <xsl:text disable-output-escaping="yes">
37 span.Location { display:inline; color : red }
38 span.Person { display:inline; color : green }
39 span.Organization { display:inline; color : yellow }
40 span.Date { display:inline; color : blue }
41 span.query_term {display: inline; background-color : yellow }
42 </xsl:text>
43 </style>
44 </xsl:template>
45
46 <xsl:template match="pageResponse">
47 <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
48 <xsl:call-template name="standardPageBanner">
49 <xsl:with-param name="collName" select="$collName"/>
50 </xsl:call-template>
51 <xsl:call-template name="navigationBar">
52 <xsl:with-param name="collName" select="$collName"/>
53 </xsl:call-template>
54 <div class="document">
55 <!-- display the document -->
56 <xsl:apply-templates select="document">
57 <xsl:with-param name="collName" select="$collName"/>
58 </xsl:apply-templates>
59 </div>
60 </xsl:template>
61
62 <xsl:template match="document">
63 <xsl:param name="collName"/>
64
65 <xsl:call-template name="documentHeading">
66 <xsl:with-param name="collName" select="$collName"/>
67 </xsl:call-template>
68
69 <xsl:call-template name="documentContent">
70 <xsl:with-param name="collName" select="$collName"/>
71 </xsl:call-template>
72 </xsl:template>
73
74 <xsl:template name="documentHeading">
75 <xsl:param name="collName"/>
76 <xsl:variable name="doCoverImage" select="/page/pageResponse/format/gsf:option[@name='coverImages']/@value"/>
77 <xsl:variable name="doTOC" select="/page/pageResponse/format/gsf:option[@name='documentTOC']/@value"/>
78 <xsl:variable name="p.a" select="/page/pageRequest/paramList/param[@name='p.a']/@value"/>
79 <xsl:variable name="p.sa" select="/page/pageRequest/paramList/param[@name='p.sa']/@value"/>
80 <xsl:variable name="p.s" select="/page/pageRequest/paramList/param[@name='p.s']/@value"/>
81 <div class="heading_image">
82 <xsl:if test="string($doCoverImage) != 'false' and (@docType='paged' or @docType='hierarchy')">
83 <xsl:call-template name="coverImage"/>
84 </xsl:if>
85 </div>
86 <div class="buttons" id="toc_buttons">
87 <xsl:call-template name="documentButtons">
88 <xsl:with-param name="collName" select="$collName"/>
89 </xsl:call-template>
90 </div>
91
92 <!--<div><xsl:call-template name="enrichServices">
93 <xsl:with-param name="collName" select="$collName"/>
94 </xsl:call-template></div>-->
95
96 <div class="toc">
97 <table class="v_list"><tr valign="top"><td valign="top"> <a href="{$library_name}?a={$p.a}&amp;sa={$p.sa}&amp;s={$p.s}&amp;c={$collName}&amp;rt=r"><xsl:call-template name="openbookimg"><xsl:with-param name="title">Close this book and return to search/browse</xsl:with-param>
98 </xsl:call-template></a></td><td valign="top"></td>
99 <td valign="top">
100 <xsl:choose><xsl:when test="@docType='simple'"><xsl:value-of select="metadataList/metadata[@name='Title']" disable-output-escaping="yes"/></xsl:when><xsl:otherwise><xsl:value-of select="documentNode/metadataList/metadata[@name='Title']" disable-output-escaping="yes"/></xsl:otherwise></xsl:choose>
101 </td></tr>
102 </table>
103 <xsl:if test="string($doTOC) != 'false'">
104 <table><tr valign="top"><td><img alt="" src="/gsdl/images/space.gif" width="25"/></td><td><table class="v_list">
105 <xsl:call-template name="TOC">
106 <xsl:with-param name="collName" select="$collName"/>
107 </xsl:call-template>
108 </table>
109 </td></tr></table>
110 </xsl:if>
111 </div>
112 </xsl:template>
113
114 <xsl:template name="coverImage">
115 <img alt="" onError="src='interfaces/default/images/blank.gif'"><xsl:attribute name='src'><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="metadataList/metadata[@name='archivedir']"/>/cover.jpg</xsl:attribute></img>
116 </xsl:template>
117
118 <xsl:template name="documentButtons">
119 <xsl:param name="collName"/>
120 <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
121 <xsl:variable name="sib" select="/page/pageRequest/paramList/param[@name='sib']/@value"/>
122 <xsl:variable name="ec" select="/page/pageRequest/paramList/param[@name='ec']/@value"/>
123 <xsl:variable name="ed" select="/page/pageRequest/paramList/param[@name='ed']/@value"/>
124
125
126 <!-- expand document -->
127 <!-- this doesn't work with MG so comment it out for now -->
128 <xsl:if test="@docType = 'hierarchy' or @docType = 'paged'">
129 <div class="button">
130 <span class="button">
131 <xsl:choose><xsl:when test="string($ed)='1'">
132 <a href="{$library_name}?a=d&amp;d={$docID}&amp;c={$collName}&amp;sib={$sib}&amp;ed=0"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.contract_doc_tip')"/></xsl:attribute>
133 <xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.contract_doc_b')"/>
134 </a>
135 </xsl:when>
136 <xsl:otherwise>
137 <a href="{$library_name}?a=d&amp;d={$docID}&amp;c={$collName}&amp;sib={$sib}&amp;ed=1"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.expand_doc_tip')"/></xsl:attribute>
138 <xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.expand_doc_b')"/>
139 </a>
140 </xsl:otherwise>
141 </xsl:choose>
142 </span>
143 </div>
144 </xsl:if>
145
146 <!-- expand contents -->
147 <xsl:if test="@docType = 'hierarchy' and string(/page/pageResponse/format/gsf:option[@name='documentTOC']/@value) != 'false'">
148 <div class="button">
149 <span class="button">
150 <xsl:choose><xsl:when test="string($ec)='1'">
151 <a href="{$library_name}?a=d&amp;d={$docID}&amp;c={$collName}&amp;sib={$sib}&amp;ec=0"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.contract_contents_tip')"/></xsl:attribute>
152 <xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.contract_contents_b')"/>
153 </a>
154 </xsl:when>
155 <xsl:otherwise>
156 <a href="{$library_name}?a=d&amp;d={$docID}&amp;c={$collName}&amp;sib={$sib}&amp;ec=1"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.expand_contents_tip')"/></xsl:attribute>
157 <xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.expand_contents_b')"/>
158 </a>
159 </xsl:otherwise>
160 </xsl:choose>
161 </span>
162 </div>
163 </xsl:if>
164 <!-- detach page -->
165 <xsl:variable name="paramList" select="/page/pageRequest/paramList"/>
166 <div class="button">
167 <span class="button">
168 <a target="_blank"><xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;d=<xsl:value-of select="$docID"/>&amp;c=<xsl:value-of select="$collName"/>&amp;sib=<xsl:value-of select="$sib"/>&amp;dt=<xsl:value-of select="$paramList/param[@name='dt']/@value"/>&amp;ec=<xsl:value-of select="$paramList/param[@name='ec']/@value"/>&amp;et=<xsl:value-of select="$paramList/param[@name='et']/@value"/>&amp;p.a=<xsl:value-of select="$paramList/param[@name='p.a']/@value"/>&amp;p.s=<xsl:value-of select="$paramList/param[@name='p.s']/@value"/>&amp;p.sa=<xsl:value-of select="$paramList/param[@name='p.sa']/@value"/></xsl:attribute><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.detach_page_tip')"/></xsl:attribute>
169 <xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.detach_page_b')"/>
170 </a>
171 </span>
172 </div>
173 </xsl:template>
174
175 <xsl:template name="TOC">
176 <xsl:param name="collName"/>
177 <xsl:choose>
178 <xsl:when test="@docType='hierarchy'">
179 <xsl:call-template name="hierarchicalContents">
180 <xsl:with-param name="collName" select="$collName"/>
181 </xsl:call-template>
182 </xsl:when>
183 <xsl:when test="@docType='paged'">
184 <xsl:call-template name="pagedContents">
185 <xsl:with-param name="collName" select="$collName"/>
186 </xsl:call-template>
187 </xsl:when>
188 </xsl:choose>
189 </xsl:template>
190
191 <xsl:template name="hierarchicalContents">
192 <xsl:param name="collName"/>
193 <xsl:variable name="oc" select="/page/pageRequest/paramList/param[@name='oc']/@value"/>
194 <xsl:variable name="d" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
195 <xsl:variable name="sib" select="/page/pageRequest/paramList/param[@name='sib']/@value"/>
196 <xsl:variable name="ec" select="/page/pageRequest/paramList/param[@name='ec']/@value"/>
197 <xsl:if test="documentNode[@nodeID]">
198 <tr valign='top'><td>
199 <xsl:choose><xsl:when test="string($oc)='0'">
200 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={$d}&amp;sib={$sib}&amp;oc=1"><xsl:call-template name="closedfolderimg"><xsl:with-param name="title">open the table of contents</xsl:with-param></xsl:call-template></a>
201 </xsl:when>
202 <xsl:otherwise><a href="{$library_name}?a=d&amp;c={$collName}&amp;d={$d}&amp;sib={$sib}&amp;oc=0"><xsl:call-template name="openfolderimg"><xsl:with-param name="title">close the table of contents</xsl:with-param></xsl:call-template></a></xsl:otherwise></xsl:choose>
203 </td><td>Table of Contents</td></tr>
204 <xsl:if test="string($oc)!='0'">
205 <tr><td>&#160;</td><td>
206 <table>
207 <xsl:for-each select="documentNode/documentNode[@nodeID]">
208 <xsl:apply-templates select='.'><xsl:with-param name="collName" select="$collName"/><xsl:with-param name="ec" select="$ec"/></xsl:apply-templates>
209 </xsl:for-each>
210 </table>
211 </td></tr>
212 </xsl:if>
213 </xsl:if>
214 </xsl:template>
215
216 <!-- each icon-title pair is a row in a table. children go in a table in another row -->
217 <xsl:template match="documentNode">
218 <xsl:param name="collName"/>
219 <xsl:param name="ec"/>
220 <!-- Display the appropriate image, depending on the node type -->
221 <tr><td valign="top">
222 <a><xsl:attribute name="href"><xsl:value-of select='$library_name'/>?a=d&amp;c=<xsl:value-of select='$collName'/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if><xsl:if test="@nodeType='leaf'">&amp;sib=1</xsl:if><xsl:if test="string($ec) = '1'">&amp;ec=1</xsl:if></xsl:attribute>
223 <xsl:apply-templates select="." mode="displayNodeIcon"/>
224 </a>
225 </td>
226
227 <!-- Display associated title, bolded if the node has content -->
228 <td valign="top">
229 <xsl:choose>
230 <xsl:when test="nodeContent">
231 <b><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></b>
232 </xsl:when>
233 <xsl:otherwise>
234 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
235 </xsl:otherwise>
236 </xsl:choose>
237 </td>
238 </tr>
239 <!-- Apply recursively to the children of this node -->
240 <xsl:if test="documentNode[@nodeID]">
241 <tr><td>&#160;</td><td><table>
242 <xsl:apply-templates select="documentNode[@nodeID]">
243 <xsl:with-param name="collName" select="$collName"/>
244 <xsl:with-param name="ec" select="$ec"/>
245 <!--<xsl:with-param name="depth" select="$depth + 1"/>-->
246 </xsl:apply-templates>
247 </table>
248 </td></tr>
249 </xsl:if>
250 </xsl:template>
251
252 <!-- default content is to print the title and content of any documentNodes that have nodeContent -->
253 <xsl:template name="documentContent">
254 <div class="documenttext">
255 <xsl:choose>
256 <xsl:when test="@docType='simple'">
257 <xsl:apply-templates select="nodeContent"/>
258 </xsl:when>
259 <xsl:otherwise>
260 <xsl:apply-templates select="descendant-or-self::node()/documentNode" mode="content"/>
261 </xsl:otherwise>
262 </xsl:choose>
263 </div>
264 </xsl:template>
265
266 <xsl:template match="documentNode" mode="content">
267 <xsl:if test="nodeContent and string(nodeContent)">
268 <xsl:if test="metadataList/metadata[@name='Title']">
269 <h3><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></h3>
270 </xsl:if>
271 <xsl:apply-templates select="nodeContent"/>
272 </xsl:if>
273
274 </xsl:template>
275
276 <!-- the actual text/content -->
277 <xsl:template match="nodeContent">
278 <p/>
279 <xsl:for-each select="node()">
280 <xsl:choose>
281 <xsl:when test="not(name())"><xsl:value-of select="." disable-output-escaping="yes"/></xsl:when>
282 <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
283 </xsl:choose>
284 </xsl:for-each>
285 </xsl:template>
286
287 <!-- match any file nodes -->
288 <xsl:template match="file">
289 <xsl:variable name="httpPath" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>
290 <xsl:choose>
291 <xsl:when test="util:isImage(@mimeType)">
292 <img src="{$httpPath}/{@href}"/>
293 </xsl:when>
294 <xsl:otherwise>
295 <a href="{$httpPath}/{@href}"><xsl:value-of select="@href"/></a>
296 </xsl:otherwise>
297 </xsl:choose>
298 </xsl:template>
299
300 <!-- match any link nodes -->
301 <xsl:template match="link">
302 <xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
303 <xsl:variable name="actionargs">
304 <xsl:choose>
305 <xsl:when test="@type='document'">a=d</xsl:when>
306 <xsl:when test="@type='query'">a=q&amp;s=<xsl:value-of select="@service"/>&amp;rt=r</xsl:when>
307 <xsl:otherwise>
308 p
309 </xsl:otherwise>
310 </xsl:choose>
311 </xsl:variable>
312 <xsl:variable name="serviceargs">
313 <xsl:for-each select="param">&amp;s1.<xsl:value-of select="@name"/>=<xsl:value-of select="@value"/></xsl:for-each>
314 </xsl:variable>
315 <a href="{$library_name}?{$actionargs}&amp;c={$collName}{$serviceargs}"><xsl:value-of disable-output-escaping="yes" select="."/></a>
316 </xsl:template>
317
318 <!-- match any annotations and make them span elements -->
319 <xsl:template match="annotation">
320 <span class="{@type}"><xsl:value-of disable-output-escaping="yes" select="."/></span>
321 </xsl:template>
322
323 <!-- paged naviagtion : INCOMPLETE!!-->
324 <xsl:template name="pagedContents">
325 <xsl:param name="collName"/>
326 <xsl:variable name="pos" select="nodeStructureInfo/info[@name='siblingPosition']/@value"/>
327 <xsl:variable name="length" select="nodeStructureInfo/info[@name='numSiblings']/@value"/>
328 <xsl:variable name="children" select="nodeStructureInfo/info[@name='numChildren']/@value"/>
329 <xsl:choose>
330 <xsl:when test="$pos=-1"><!-- a doc -->
331 <tr valign="top">
332 <td align="left">
333 </td>
334 <td align="center"><center>
335 <b><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'document.pages', $children)"/></b>
336 </center></td>
337 <td align="right">
338 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@selectedNode}.fc"><img src="interfaces/default/images/more.gif" border="0" align="absbottom" /></a>
339 </td>
340 </tr>
341 </xsl:when>
342
343 <xsl:otherwise> <!-- an internal node -->
344 <tr valign="top">
345 <td align="left">
346 <xsl:if test=" not ( $pos = 1 )">
347 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@selectedNode}.ps"><img src="interfaces/default/images/less.gif" border="0" align="absbottom" /></a>
348 </xsl:if>
349 </td>
350 <td align="center"><center>
351 <b><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'document.pageof', concat($pos, ';', $length))"/></b>
352 </center></td>
353 <td align="right">
354 <xsl:if test=" not($pos = $length)">
355 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@selectedNode}.ns"><img src="interfaces/default/images/more.gif" border="0" align="absbottom" /></a>
356 </xsl:if>
357 </td>
358 </tr>
359 </xsl:otherwise>
360 </xsl:choose>
361 <tr valign="middle">
362 <td align='center' valign='top' colspan='3'>
363 <form name="GotoForm" method="get" action="{$library_name}">
364 <input type='hidden' name='a' value='d'/>
365 <input type='hidden' name='c' value='{$collName}'/>
366 <input type='hidden' name='d' value='{@selectedNode}'/>
367 <input type="text" name="gp" size="3" maxlength="4"/>
368 <input type="submit"><xsl:attribute name='value'><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'document.gotopage')"/></xsl:attribute></input>
369 </form>
370 </td>
371 </tr>
372 </xsl:template>
373
374 <xsl:template name="enrichServices">
375 <xsl:param name="collName"/>
376 <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
377 <xsl:variable name="request-params" select="/page/pageRequest/paramList"/>
378 <xsl:for-each select="../serviceList/service">
379 <table border='1' cellspacing='0'>
380 <tr><td>
381 <p /><xsl:value-of select="displayItem[@name='name']"/><p/>
382 <form name="EnrichForm" method="get" action="{$library_name}">
383 <xsl:apply-templates select="paramList"/>
384 <input type='hidden' name='a' value='d'/>
385 <input type='hidden' name='d' value='{$docID}'/>
386 <input type='hidden' name='c' value='{$collName}'/>
387 <xsl:if test='$request-params/param[@name="sib"]'>
388 <input type='hidden' name='sib'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="sib"]/@value'/></xsl:attribute></input></xsl:if>
389 <input type='hidden' name='s' value='{@name}'/>
390 <input type='hidden' name='p.a'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="p.a"]'/></xsl:attribute></input>
391 <input type='hidden' name='p.sa'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="p.sa"]'/></xsl:attribute></input>
392 <input type='hidden' name='p.s'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="p.s"]'/></xsl:attribute></input>
393 <input type='hidden' name='end' value='1'/>
394 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input>
395 </form>
396 </td></tr>
397 </table>
398 </xsl:for-each>
399 </xsl:template>
400
401 <xsl:template match="paramList" mode="hidden">
402 <xsl:for-each select="param">
403 <input type='hidden' name='{@name}' value='{@value}'/><xsl:text>
404 </xsl:text>
405 </xsl:for-each>
406 </xsl:template>
407
408</xsl:stylesheet>
409
410
411
412
Note: See TracBrowser for help on using the repository browser.