source: trunk/gsdl3/web/interfaces/default/transform/document.xsl@ 8529

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

brownbutton changed to gsbutton, cos its no longer brown

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