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

Last change on this file since 6373 was 6373, checked in by kjdon, 20 years ago

small changes

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