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

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

link to previous search/browse page now looks for p.c, in case come from a different collection to the one we are in. needed for cross coll searching

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