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

Last change on this file since 9874 was 9874, checked in by kjdon, 19 years ago

merged from branch ant-install-branch: merge 1

  • Property svn:keywords set to Author Date Id Revision
File size: 19.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: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 style="background-image: none;">
20 <center>
21 <xsl:apply-templates select="pageResponse"/>
22 <xsl:call-template name="greenstoneFooter"/>
23 </center>
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 <table width="537">
49 <tr><td>
50 <xsl:call-template name="standardPageBanner">
51 <xsl:with-param name="collName" select="$collName"/>
52 </xsl:call-template>
53 <xsl:call-template name="navigationBar">
54 <xsl:with-param name="collName" select="$collName"/>
55 </xsl:call-template>
56 </td></tr></table>
57 <!-- display the document -->
58 <xsl:apply-templates select="document">
59 <xsl:with-param name="collName" select="$collName"/>
60 </xsl:apply-templates>
61 <table width='537'><tr><td>
62 <xsl:call-template name="dividerBar"/>
63 </td></tr></table>
64 </xsl:template>
65
66 <xsl:template match="document">
67 <xsl:param name="collName"/>
68 <table width='537'><tr><td>
69 <xsl:call-template name="documentHeading">
70 <xsl:with-param name="collName" select="$collName"/>
71 </xsl:call-template>
72 </td></tr></table>
73 <xsl:call-template name="documentContent">
74 <xsl:with-param name="collName" select="$collName"/>
75 </xsl:call-template>
76 </xsl:template>
77
78 <xsl:template name="documentHeading">
79 <xsl:param name="collName"/>
80 <xsl:variable name="doCoverImage" select="/page/pageResponse/format/gsf:option[@name='coverImages']/@value"/>
81 <xsl:variable name="doTOC" select="/page/pageResponse/format/gsf:option[@name='documentTOC']/@value"/>
82 <xsl:variable name="p.a" select="/page/pageRequest/paramList/param[@name='p.a']/@value"/>
83 <xsl:variable name="p.sa" select="/page/pageRequest/paramList/param[@name='p.sa']/@value"/>
84 <xsl:variable name="p.s" select="/page/pageRequest/paramList/param[@name='p.s']/@value"/>
85 <table><tr><td>
86 <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>
87 </xsl:call-template></a></td>
88 <td valign='top'><b><font size="+1">&#160;
89 <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>
90 </font></b></td>
91 </tr></table>
92
93 <table cellpadding="10" cellspacing="0">
94 <tr>
95 <td valign="top" align="left">
96 <xsl:if test="string($doCoverImage) != 'false' and (@docType='paged' or @docType='hierarchy')">
97 <xsl:call-template name="coverImage"/>
98 <p/>
99 </xsl:if>
100
101 <xsl:call-template name="documentButtons">
102 <xsl:with-param name="collName" select="$collName"/>
103 </xsl:call-template>
104 <!--<xsl:call-template name="enrichServices">
105 <xsl:with-param name="collName" select="$collName"/>
106 </xsl:call-template>-->
107 </td>
108 <xsl:if test="string($doTOC) != 'false'">
109 <td valign="top" align="left">
110 <xsl:call-template name="TOC">
111 <xsl:with-param name="collName" select="$collName"/>
112 </xsl:call-template>
113 </td>
114 </xsl:if>
115 </tr>
116 </table>
117 </xsl:template>
118
119 <xsl:template name="coverImage">
120 <img alt="" onError="src='interfaces/classic/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>
121 </xsl:template>
122
123 <xsl:template name="documentButtons">
124 <xsl:param name="collName"/>
125 <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
126 <xsl:variable name="sib" select="/page/pageRequest/paramList/param[@name='sib']/@value"/>
127 <xsl:variable name="ec" select="/page/pageRequest/paramList/param[@name='ec']/@value"/>
128 <xsl:variable name="ed" select="/page/pageRequest/paramList/param[@name='ed']/@value"/>
129
130 <table>
131 <!-- expand document -->
132 <!-- this doesn't work with MG so comment it out for now -->
133
134 <xsl:if test="@docType = 'hierarchy' or @docType = 'paged'">
135 <tr><td class="gsbutton">
136 <xsl:choose><xsl:when test="string($ed)='1'">
137 <a class="gsbutton" 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>
138 <font size='-2'><xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.contract_doc_b')"/></font>
139 </a>
140 </xsl:when>
141 <xsl:otherwise>
142 <a class="gsbutton" 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>
143 <font size='-2'><xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.expand_doc_b')"/></font>
144 </a>
145 </xsl:otherwise>
146 </xsl:choose>
147 </td></tr>
148 </xsl:if>
149
150 <!-- expand contents -->
151 <xsl:if test="@docType = 'hierarchy' and string(/page/pageResponse/format/gsf:option[@name='documentTOC']/@value) != 'false'">
152 <tr><td class="gsbutton">
153 <xsl:choose><xsl:when test="string($ec)='1'">
154 <a class="gsbutton" 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>
155 <font size='-2'><xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.contract_contents_b')"/></font>
156 </a>
157 </xsl:when>
158 <xsl:otherwise>
159 <a class="gsbutton" 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>
160 <font size='-2'><xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.expand_contents_b')"/></font>
161 </a>
162 </xsl:otherwise>
163 </xsl:choose>
164 </td></tr>
165 </xsl:if>
166 <!-- detach page -->
167 <xsl:variable name="paramList" select="/page/pageRequest/paramList"/>
168 <tr><td class="gsbutton">
169 <a class="gsbutton" 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>
170 <font size='-2'><xsl:value-of disable-output-escaping='yes' select="util:getInterfaceText($interface_name, /page/@lang, 'doc.detach_page_b')"/></font>
171 </a></td></tr>
172 </table>
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 <table>
199 <tr valign='top'><td>
200 <xsl:choose><xsl:when test="string($oc)='0'">
201 <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>
202 </xsl:when>
203 <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>
204 </td><td>Table of Contents</td></tr>
205 <xsl:if test="string($oc)!='0'">
206 <tr><td>&#160;</td><td>
207 <table>
208 <xsl:for-each select="documentNode/documentNode[@nodeID]">
209 <xsl:apply-templates select='.'><xsl:with-param name="collName" select="$collName"/><xsl:with-param name="ec" select="$ec"/></xsl:apply-templates>
210 </xsl:for-each>
211 </table>
212 </td></tr>
213 </xsl:if>
214 </table>
215 </xsl:if>
216 </xsl:template>
217
218 <!-- each icon-title pair is a row in a table. children go in a table in another row -->
219 <xsl:template match="documentNode">
220 <xsl:param name="collName"/>
221 <xsl:param name="ec"/>
222 <!-- Display the appropriate image, depending on the node type -->
223 <tr><td valign="top">
224 <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>
225 <xsl:apply-templates select="." mode="displayNodeIcon"/>
226 </a>
227 </td>
228
229 <!-- Display associated title, bolded if the node has content -->
230 <td valign="top">
231 <xsl:choose>
232 <xsl:when test="nodeContent">
233 <b><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></b>
234 </xsl:when>
235 <xsl:otherwise>
236 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
237 </xsl:otherwise>
238 </xsl:choose>
239 </td>
240 </tr>
241 <!-- Apply recursively to the children of this node -->
242 <xsl:if test="documentNode[@nodeID]">
243 <tr><td>&#160;</td><td><table>
244 <xsl:apply-templates select="documentNode[@nodeID]">
245 <xsl:with-param name="collName" select="$collName"/>
246 <xsl:with-param name="ec" select="$ec"/>
247 <!--<xsl:with-param name="depth" select="$depth + 1"/>-->
248 </xsl:apply-templates>
249 </table>
250 </td></tr>
251 </xsl:if>
252 </xsl:template>
253
254 <!-- default content is to print the title and content of any documentNodes that have nodeContent -->
255 <xsl:template name="documentContent">
256 <div align="left">
257 <xsl:choose>
258 <xsl:when test="@docType='simple'">
259 <xsl:apply-templates select="nodeContent"/>
260 </xsl:when>
261 <xsl:otherwise>
262 <xsl:apply-templates select="descendant-or-self::node()/documentNode" mode="content"/>
263 </xsl:otherwise>
264 </xsl:choose>
265 </div>
266 </xsl:template>
267
268 <xsl:template match="documentNode" mode="content">
269 <xsl:if test="nodeContent and string(nodeContent)">
270 <xsl:if test="metadataList/metadata[@name='Title']">
271 <h3><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></h3>
272 </xsl:if>
273 <xsl:apply-templates select="nodeContent"/>
274 </xsl:if>
275
276 </xsl:template>
277
278 <!-- the actual text/content -->
279 <xsl:template match="nodeContent">
280 <p/>
281 <xsl:for-each select="node()">
282 <xsl:choose>
283 <xsl:when test="not(name())"><xsl:value-of select="." disable-output-escaping="yes"/></xsl:when>
284 <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
285 </xsl:choose>
286 </xsl:for-each>
287 </xsl:template>
288
289 <!-- match any file nodes -->
290 <xsl:template match="file">
291 <xsl:variable name="httpPath" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>
292 <xsl:choose>
293 <xsl:when test="util:isImage(@mimeType)">
294 <img src="{$httpPath}/{@href}"/>
295 </xsl:when>
296 <xsl:otherwise>
297 <a href="{$httpPath}/{@href}"><xsl:value-of select="@href"/></a>
298 </xsl:otherwise>
299 </xsl:choose>
300 </xsl:template>
301
302 <!-- match any link nodes -->
303 <xsl:template match="link">
304 <xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
305 <xsl:variable name="actionargs">
306 <xsl:choose>
307 <xsl:when test="@type='document'">a=d</xsl:when>
308 <xsl:when test="@type='query'">a=q&amp;s=<xsl:value-of select="@service"/>&amp;rt=r</xsl:when>
309 <xsl:otherwise>
310 p
311 </xsl:otherwise>
312 </xsl:choose>
313 </xsl:variable>
314 <xsl:variable name="serviceargs">
315 <xsl:for-each select="param">&amp;s1.<xsl:value-of select="@name"/>=<xsl:value-of select="@value"/></xsl:for-each>
316 </xsl:variable>
317 <a href="{$library_name}?{$actionargs}&amp;c={$collName}{$serviceargs}"><xsl:value-of disable-output-escaping="yes" select="."/></a>
318 </xsl:template>
319
320 <!-- match any annotations and make them span elements -->
321 <xsl:template match="annotation">
322 <span class="{@type}"><xsl:value-of disable-output-escaping="yes" select="."/></span>
323 </xsl:template>
324
325 <!-- paged naviagtion : INCOMPLETE!!-->
326 <xsl:template name="pagedContents">
327 <xsl:param name="collName"/>
328 <xsl:variable name="pos" select="nodeStructureInfo/info[@name='siblingPosition']/@value"/>
329 <xsl:variable name="length" select="nodeStructureInfo/info[@name='numSiblings']/@value"/>
330 <xsl:variable name="children" select="nodeStructureInfo/info[@name='numChildren']/@value"/>
331 <table>
332 <xsl:choose>
333 <xsl:when test="$pos=-1"><!-- a doc -->
334 <tr valign="top">
335 <td align="left">
336 </td>
337 <td align="center"><center>
338 <b><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'document.pages', $children)"/></b>
339 </center></td>
340 <td align="right">
341 <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>
342 </td>
343 </tr>
344 </xsl:when>
345
346 <xsl:otherwise> <!-- an internal node -->
347 <tr valign="top">
348 <td align="left">
349 <xsl:if test=" not ( $pos = 1 )">
350 <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>
351 </xsl:if>
352 </td>
353 <td align="center"><center>
354 <b><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'document.pageof', concat($pos, ';', $length))"/></b>
355 </center></td>
356 <td align="right">
357 <xsl:if test=" not($pos = $length)">
358 <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>
359 </xsl:if>
360 </td>
361 </tr>
362 </xsl:otherwise>
363 </xsl:choose>
364 <tr valign="middle">
365 <td align='center' valign='top' colspan='3'>
366 <form name="GotoForm" method="get" action="{$library_name}">
367 <input type='hidden' name='a' value='d'/>
368 <input type='hidden' name='c' value='{$collName}'/>
369 <input type='hidden' name='d' value='{@selectedNode}'/>
370 <input type="text" name="gp" size="3" maxlength="4"/>
371 <input type="submit"><xsl:attribute name='value'><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'document.gotopage')"/></xsl:attribute></input>
372 </form>
373 </td>
374 </tr>
375 </table>
376 </xsl:template>
377
378 <xsl:template name="enrichServices">
379 <xsl:param name="collName"/>
380 <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
381 <xsl:variable name="request-params" select="/page/pageRequest/paramList"/>
382 <xsl:for-each select="../serviceList/service">
383 <table border='1' cellspacing='0'>
384 <tr><td>
385 <p /><xsl:value-of select="displayItem[@name='name']"/><p/>
386 <form name="EnrichForm" method="get" action="{$library_name}">
387 <xsl:apply-templates select="paramList"/>
388 <input type='hidden' name='a' value='d'/>
389 <input type='hidden' name='d' value='{$docID}'/>
390 <input type='hidden' name='c' value='{$collName}'/>
391 <xsl:if test='$request-params/param[@name="sib"]'>
392 <input type='hidden' name='sib'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="sib"]/@value'/></xsl:attribute></input></xsl:if>
393 <input type='hidden' name='s' value='{@name}'/>
394 <input type='hidden' name='p.a'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="p.a"]'/></xsl:attribute></input>
395 <input type='hidden' name='p.sa'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="p.sa"]'/></xsl:attribute></input>
396 <input type='hidden' name='p.s'><xsl:attribute name='value'><xsl:value-of select='$request-params/param[@name="p.s"]'/></xsl:attribute></input>
397 <input type='hidden' name='end' value='1'/>
398 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input>
399 </form>
400 </td></tr>
401 </table>
402 </xsl:for-each>
403 </xsl:template>
404
405 <xsl:template match="paramList" mode="hidden">
406 <xsl:for-each select="param">
407 <input type='hidden' name='{@name}' value='{@value}'/><xsl:text>
408 </xsl:text>
409 </xsl:for-each>
410 </xsl:template>
411
412</xsl:stylesheet>
413
414
415
416
Note: See TracBrowser for help on using the repository browser.