root/main/branches/64_bit_Greenstone/greenstone3/web/interfaces/default/transform/document.xsl @ 24007

Revision 24007, 29.2 KB (checked in by sjm84, 8 years ago)

Updating this branch to match the latest Greenstone3 changes

  • Property svn:keywords set to Author Date Id Revision
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:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
6  extension-element-prefixes="java"
7  exclude-result-prefixes="java gsf">
8
9  <!-- style includes global params interface_name, library_name -->
10  <xsl:include href="style.xsl"/>
11  <xsl:include href="service-params.xsl"/>
12  <xsl:include href="berrytools.xsl"/>
13
14  <xsl:output method="html"/>
15 
16  <!-- the main page layout template is here -->
17  <xsl:template match="page">
18    <xsl:variable name="bookswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xsl:variable>
19    <xsl:variable name="a"><xsl:value-of select="/page/pageRequest/paramList/param[@name='a']/@value"/></xsl:variable>
20
21    <xsl:choose>
22      <xsl:when test="$bookswitch = 'flashxml' and $a = 'd'">
23    <html>
24      <xsl:call-template name="response" />
25        </html>
26      </xsl:when>
27
28      <xsl:otherwise>   
29        <html>
30      <head>
31        <title>
32          <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
33          <xsl:call-template name="pageTitle"/><xsl:text> </xsl:text>
34        </title>
35        <xsl:call-template name="globalStyle"/>
36        <xsl:call-template name="pageStyle"/>
37      </head>
38          <body>
39        <xsl:attribute name="dir"><xsl:call-template name="direction"/></xsl:attribute>
40        <div id="page-wrapper">
41          <xsl:call-template name="response" />
42          <xsl:call-template name="greenstoneFooter"/>
43        </div>
44          </body>
45        </html>
46      </xsl:otherwise>
47    </xsl:choose>
48  </xsl:template>
49 
50 
51  <xsl:variable name="berrybasketswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:variable>
52  <xsl:variable name="bookswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xsl:variable>
53 
54  <xsl:template name="pageTitle">
55    <xsl:variable name="docID" select="/page/pageResponse/document/@selectedNode"/>
56    <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>
57  </xsl:template>
58
59  <!-- this is hard coded for GATE, should somehow do it dynamically-->
60  <xsl:template name="pageStyle">
61    <style type="text/css">
62      <xsl:text disable-output-escaping="yes">
63    span.Location {  display:inline; color : red }
64    span.Person {  display:inline; color : green }
65    span.Organization {  display:inline; color : yellow }
66    span.Date {  display:inline; color : blue }
67    span.query_term {display: inline; background-color : yellow }
68      </xsl:text>
69    </style>
70
71    <!--TODO: add berry basket switch-->
72    <!--<xsl:if test="$berryBaskets = 'true'">-->
73    <xsl:if test="$berrybasketswitch = 'on'">
74      <xsl:call-template name="berryStyleSheet"/> 
75      <xsl:call-template name="js-library"/>
76    </xsl:if>
77  </xsl:template>
78 
79  <xsl:template match="pageResponse">
80    <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
81    <xsl:choose>
82      <xsl:when test="$bookswitch = 'on' or $bookswitch = 'off'">
83        <xsl:call-template name="standardPageBanner">
84      <xsl:with-param name="collName" select="$collName"/>
85        </xsl:call-template>
86        <xsl:call-template name="navigationBar">
87      <xsl:with-param name="collName" select="$collName"/>
88        </xsl:call-template>
89   
90        <!--<xsl:if test="$berryBaskets = 'true'">-->
91        <xsl:if test="$berrybasketswitch = 'on'">
92          <xsl:call-template name="documentBerryBasket">
93        <xsl:with-param name="collName" select="$collName"/>
94        <xsl:with-param name="selectedNode" select="/page/pageResponse/document/@selectedNode"/>
95        <xsl:with-param name="rootNode" select="/page/pageResponse/document/documentNode[@nodeType='root']/@nodeID"/>
96        <xsl:with-param name="docType" select="/page/pageResponse/document/@docType"/>
97          </xsl:call-template>
98        </xsl:if>
99      </xsl:when>
100    </xsl:choose>   
101
102    <!-- display the document -->
103    <xsl:if test="$bookswitch != 'flashxml'">
104      <xsl:text disable-output-escaping="yes">&lt;div id="content"&gt;</xsl:text>
105    </xsl:if>
106    <xsl:apply-templates select="document">
107      <xsl:with-param name="collName" select="$collName"/>
108    </xsl:apply-templates>
109    <xsl:if test="$bookswitch != 'flashxml'">
110      <xsl:text disable-output-escaping="yes">&lt;/div&gt;</xsl:text>
111    </xsl:if>
112  </xsl:template>
113 
114  <xsl:template match="document">
115    <xsl:param name="collName"/>
116    <xsl:variable name="external"><xsl:value-of select="/page/pageResponse/document/@external"/></xsl:variable>
117    <xsl:choose>
118      <xsl:when test="$external != ''">
119    <xsl:call-template name="externalPage">
120      <xsl:with-param name="external" select="$external"/>
121    </xsl:call-template>
122      </xsl:when>
123      <xsl:otherwise>
124    <xsl:choose>
125    <xsl:when test="$bookswitch = 'flashxml'">
126      <xsl:call-template name="xmldocumentContentPeeling">
127        <xsl:with-param name="collName" select="$collName"/>
128      </xsl:call-template>
129    </xsl:when>
130   
131    <xsl:when test="$bookswitch = 'on'">
132      <xsl:call-template name="documentHeading">
133        <xsl:with-param name="collName" select="$collName"/>
134      </xsl:call-template>
135      <div id="bookdiv"></div>
136      <script type="text/javascript">
137        <xsl:text disable-output-escaping="yes">
138          var doc_url = document.URL;
139          doc_url = doc_url.replace(/(&amp;amp;|\?)book=[a-z]+/gi,'');
140          doc_url += '&amp;amp;book=flashxml';
141
142          var flash_plug_html = ""
143          flash_plug_html += '&amp;lt;OBJECT align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \n';
144          flash_plug_html += '  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \n';
145          flash_plug_html += '  height="100%" id="Book" swLiveConnect="true" \n';
146          flash_plug_html += '  width="100%"&amp;gt;\n';
147          flash_plug_html += '    &amp;lt;PARAM name="allowScriptAccess" value="always" /&amp;gt;\n';
148          flash_plug_html += '    &amp;lt;PARAM name="movie" value="Book.swf';
149          flash_plug_html += '?src_image=' + escape(img_cover);
150          flash_plug_html += '&amp;amp;doc_url=' + escape(doc_url)
151          flash_plug_html += '" /&amp;gt;\n';
152          flash_plug_html += '    &amp;lt;PARAM name="quality" value="high" /&amp;gt;\n';
153          flash_plug_html += '    &amp;lt;PARAM name="bgcolor" value="#FFFFFF" /&amp;gt;\n';
154          flash_plug_html += '    &amp;lt;EMBED align="middle" \n';
155          flash_plug_html += '      allowScriptAccess="always" swLiveConnect="true" \n';
156          flash_plug_html += '      bgcolor="#FFFFFF" height="100%" name="Book" \n';
157          flash_plug_html += '      pluginspage="http://www.macromedia.com/go/getflashplayer" \n';
158          flash_plug_html += '      quality="high" \n';
159          flash_plug_html += '      src="Book.swf';
160          flash_plug_html += '?src_image=' + escape(img_cover);
161          flash_plug_html += '&amp;amp;doc_url=' + escape(doc_url);
162          flash_plug_html += '"\n';
163          flash_plug_html += '      type="application/x-shockwave-flash" width="100%" /&amp;gt;\n';
164          flash_plug_html += '&amp;lt;/OBJECT&amp;gt;\n';
165          var flash_div = document.getElementById("bookdiv");
166          flash_div.innerHTML = flash_plug_html;
167        </xsl:text>
168      </script>
169    </xsl:when>
170    <xsl:otherwise>
171      <xsl:call-template name="documentHeading">
172        <xsl:with-param name="collName" select="$collName"/>
173      </xsl:call-template>
174     
175      <xsl:call-template name="documentArrows">
176        <xsl:with-param name="collName" select="$collName"/>
177      </xsl:call-template>         
178      <xsl:call-template name="documentContent">
179        <xsl:with-param name="collName" select="$collName"/>
180      </xsl:call-template>
181      <xsl:call-template name="documentArrows">
182        <xsl:with-param name="collName" select="$collName"/>
183      </xsl:call-template>   
184    </xsl:otherwise>
185    </xsl:choose>
186   
187      </xsl:otherwise>
188    </xsl:choose>
189  </xsl:template>
190
191  <xsl:template name="documentHeading">
192    <xsl:param name="collName"/>
193    <xsl:variable name="doCoverImage" select="/page/pageResponse/format/gsf:option[@name='coverImages']/@value"/>
194    <xsl:variable name="doTOC" select="/page/pageResponse/format/gsf:option[@name='documentTOC']/@value"/>
195    <xsl:variable name="p.a" select="/page/pageRequest/paramList/param[@name='p.a']/@value"/>
196    <xsl:variable name="p.sa" select="/page/pageRequest/paramList/param[@name='p.sa']/@value"/>
197    <xsl:variable name="p.s" select="/page/pageRequest/paramList/param[@name='p.s']/@value"/>
198    <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>
199    <div id="documentheading">
200      <a href="{$library_name}?a={$p.a}&amp;amp;sa={$p.sa}&amp;amp;s={$p.s}&amp;amp;c={$p.c}&amp;amp;rt=rd"><xsl:call-template name="openbookimg"><xsl:with-param name="title"><xsl:value-of select="'close_book'"/></xsl:with-param>
201    </xsl:call-template></a>
202      <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>
203    </div>
204   
205    <div id="docheadwrapper">
206      <div id="documentinfo">
207   
208    <xsl:choose>
209      <xsl:when test="$bookswitch = 'on'">
210        <xsl:if test="string($doCoverImage) != 'false' and (@docType='paged' or @docType='hierarchy')">
211          <div id="headingimage">
212        <xsl:call-template name="coverImage"/>
213          </div>
214        </xsl:if>
215      </xsl:when>
216      <xsl:otherwise>
217        <xsl:if test="string($doCoverImage) != 'false' and (@docType='paged' or @docType='hierarchy')">
218          <div id="headingimage">
219        <xsl:call-template name="coverImage"/>
220          </div>
221        </xsl:if>
222       
223        <ul id="docbuttons" >
224          <xsl:call-template name="documentButtons">
225        <xsl:with-param name="collName" select="$collName"/>
226          </xsl:call-template>
227        </ul>
228      </xsl:otherwise>
229    </xsl:choose>     
230      </div>
231      <!--<div><xsl:call-template name="enrichServices">
232      <xsl:with-param name="collName" select="$collName"/>
233    </xsl:call-template></div>-->
234      <xsl:if test="$bookswitch = 'off'">
235    <xsl:if test="string($doTOC) != 'false'">
236      <div id="toc">
237        <xsl:call-template name="TOC">
238          <xsl:with-param name="collName" select="$collName"/>
239        </xsl:call-template>
240      </div>
241    </xsl:if>
242      </xsl:if> 
243    </div>
244  </xsl:template>
245
246  <xsl:template name="coverImage">
247    <xsl:choose>
248      <xsl:when test="$bookswitch = 'on'">
249    <script type="text/javascript">
250      <xsl:text disable-output-escaping="yes">var img_cover = '</xsl:text><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="metadataList/metadata[@name='archivedir']"/>/cover.jpg<xsl:text disable-output-escaping="yes">';</xsl:text>
251    </script>
252      </xsl:when>
253      <xsl:otherwise>
254    <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>
255      </xsl:otherwise>
256    </xsl:choose>
257  </xsl:template>
258
259  <xsl:template name="documentButtons">
260    <xsl:param name="collName"/>
261    <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
262    <xsl:variable name="sib" select="/page/pageRequest/paramList/param[@name='sib']/@value"/>
263    <xsl:variable name="ec" select="/page/pageRequest/paramList/param[@name='ec']/@value"/>
264    <xsl:variable name="ed" select="/page/pageRequest/paramList/param[@name='ed']/@value"/>
265   
266   
267    <!-- expand document -->
268    <xsl:if test="@docType = 'hierarchy' or @docType = 'paged'">
269      <li>
270        <xsl:choose><xsl:when test="string($ed)='1'">
271        <a href="{$library_name}?a=d&amp;amp;d={$docID}&amp;amp;c={$collName}&amp;amp;sib={$sib}&amp;amp;ed=0" class="getTextFor doc.contract_doc_b this.title.doc.contract_doc_tip"></a>
272      </xsl:when>
273      <xsl:otherwise>
274        <a href="{$library_name}?a=d&amp;amp;d={$docID}&amp;amp;c={$collName}&amp;amp;sib={$sib}&amp;amp;ed=1" class="getTextFor doc.expand_doc_b this.title.doc.expand_doc_tip"></a>
275      </xsl:otherwise>
276    </xsl:choose>
277      </li>
278    </xsl:if>
279   
280    <!-- expand contents -->
281    <xsl:if test="@docType = 'hierarchy' and string(/page/pageResponse/format/gsf:option[@name='documentTOC']/@value) != 'false'">
282      <li>
283    <xsl:choose><xsl:when test="string($ec)='1'">
284        <a href="{$library_name}?a=d&amp;amp;d={$docID}&amp;amp;c={$collName}&amp;amp;sib={$sib}&amp;amp;ec=0" class="getTextFor doc.contract_contents_b this.title.doc.contract_contents_tip"></a>
285      </xsl:when>
286      <xsl:otherwise>
287        <a  href="{$library_name}?a=d&amp;amp;d={$docID}&amp;amp;c={$collName}&amp;amp;sib={$sib}&amp;amp;ec=1" class="getTextFor doc.expand_contents_b this.title.doc.expand_contents_tip"></a>
288      </xsl:otherwise>
289    </xsl:choose>
290      </li>
291    </xsl:if>
292
293    <!-- detach page -->
294    <xsl:variable name="paramList" select="/page/pageRequest/paramList"/>
295    <li>
296      <a target="_blank" class="getTextFor doc.detach_page_b this.title.doc.detach_page_tip"><xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;amp;d=<xsl:value-of select="$docID"/>&amp;amp;c=<xsl:value-of select="$collName"/>&amp;amp;sib=<xsl:value-of select="$sib"/>&amp;amp;dt=<xsl:value-of select="$paramList/param[@name='dt']/@value"/>&amp;amp;ec=<xsl:value-of select="$paramList/param[@name='ec']/@value"/>&amp;amp;et=<xsl:value-of select="$paramList/param[@name='et']/@value"/>&amp;amp;p.a=<xsl:value-of select="$paramList/param[@name='p.a']/@value"/>&amp;amp;p.s=<xsl:value-of select="$paramList/param[@name='p.s']/@value"/>&amp;amp;p.sa=<xsl:value-of select="$paramList/param[@name='p.sa']/@value"/></xsl:attribute></a></li>
297  </xsl:template>
298
299  <xsl:template name="TOC">
300    <xsl:param name="collName"/>
301    <xsl:choose>
302      <xsl:when test="@docType='hierarchy'">
303    <xsl:call-template name="hierarchicalContents">
304      <xsl:with-param name="collName" select="$collName"/>
305    </xsl:call-template>
306      </xsl:when>
307      <xsl:when test="@docType='paged'">
308    <xsl:call-template name="pagedContents">
309      <xsl:with-param name="collName" select="$collName"/>
310    </xsl:call-template>
311      </xsl:when>
312    </xsl:choose>
313  </xsl:template>
314 
315  <xsl:template name="hierarchicalContents">
316    <xsl:param name="collName"/>
317    <xsl:variable name="oc" select="/page/pageRequest/paramList/param[@name='oc']/@value"/>
318    <xsl:variable name="d" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
319    <xsl:variable name="sib" select="/page/pageRequest/paramList/param[@name='sib']/@value"/>
320    <xsl:variable name="ec" select="/page/pageRequest/paramList/param[@name='ec']/@value"/>
321    <xsl:variable name="p.s" select="/page/pageRequest/paramList/param[@name='p.s']/@value"/>
322    <xsl:variable name="p.sa" select="/page/pageRequest/paramList/param[@name='p.sa']/@value"/>
323    <xsl:variable name="p.a" select="/page/pageRequest/paramList/param[@name='p.a']/@value"/>
324    <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>
325    <script type="text/javascript">
326      <xsl:text>
327        // Load up the initial document using AJAX!
328        var initialHash = '</xsl:text>
329      <xsl:value-of select="$d" /><xsl:text>';
330      </xsl:text>
331    </script>
332    <xsl:if test="documentNode[@nodeID]">     
333      <ul id="tocnodes">
334    <li id="tocstart">
335      <xsl:choose><xsl:when test="string($oc)='0'">
336          <a href="{$library_name}?a=d&amp;amp;c={$collName}&amp;amp;d={$d}&amp;amp;sib={$sib}&amp;amp;oc=1&amp;amp;p.s={$p.s}&amp;amp;p.sa={$p.sa}&amp;amp;p.a={$p.a}&amp;amp;p.c={$p.c}"><xsl:call-template name="closedfolderimg"><xsl:with-param name="title"><xsl:value-of select="'doc.open_toc'"/></xsl:with-param></xsl:call-template></a>
337        </xsl:when>
338        <xsl:otherwise><a href="{$library_name}?a=d&amp;amp;c={$collName}&amp;amp;d={$d}&amp;amp;sib={$sib}&amp;amp;oc=0&amp;amp;p.s={$p.s}&amp;amp;p.sa={$p.sa}&amp;amp;p.a={$p.a}&amp;amp;p.c={$p.c}"><xsl:call-template name="openfolderimg"><xsl:with-param name="title"><xsl:value-of select="'doc.close_toc'"/></xsl:with-param></xsl:call-template></a></xsl:otherwise></xsl:choose><span class="getTextFor doc.table_of_contents">&amp;amp;nbsp;</span>
339      <xsl:if test="string($oc)!='0'">
340        <ul class="tocnode">
341          <xsl:for-each select="documentNode/documentNode[@nodeID]">
342        <xsl:apply-templates select='.'><xsl:with-param name="collName" select="$collName"/><xsl:with-param name="ec" select="$ec"/><xsl:with-param name="p.a" select="$p.a"/><xsl:with-param name="p.s" select="$p.s"/><xsl:with-param name="p.sa" select="$p.sa"/><xsl:with-param name="p.c" select="$p.c"/></xsl:apply-templates>
343          </xsl:for-each>
344            </ul>
345      </xsl:if>
346        </li>
347      </ul>
348    </xsl:if>
349  </xsl:template>
350 
351  <!-- each icon-title pair is a row in a table. children go in a table in another row -->
352  <xsl:template match="documentNode">
353    <xsl:param name="collName"/>
354    <xsl:param name="ec"/>
355    <xsl:param name="p.a"/>
356    <xsl:param name="p.s"/>
357    <xsl:param name="p.sa"/>
358    <xsl:param name="p.c"/>
359    <!-- Display the appropriate image, depending on the node type -->
360    <li>
361      <a><xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;amp;c=<xsl:value-of select="$collName"/>&amp;amp;d=<xsl:value-of select="@nodeID"/><xsl:if test="documentNode">.pr</xsl:if>&amp;amp;sib=1<xsl:if test="string($ec) = '1'">&amp;amp;ec=1</xsl:if>&amp;amp;p.a=<xsl:value-of select="$p.a"/>&amp;amp;p.sa=<xsl:value-of select="$p.sa"/>&amp;amp;p.s=<xsl:value-of select="$p.s"/>&amp;amp;p.c=<xsl:value-of select="$p.c"/></xsl:attribute>
362    <xsl:apply-templates select="." mode="displayNodeIcon"/>
363      </a>
364     
365      <!-- Display associated title, bolded if the node has content -->
366      <xsl:choose>
367    <xsl:when test="nodeContent">
368      <span class="bold"><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></span>
369    </xsl:when>
370    <xsl:otherwise>
371      <span><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></span>
372    </xsl:otherwise>
373      </xsl:choose>
374      <!-- Apply recursively to the children of this node -->
375      <xsl:if test="documentNode[@nodeID]">
376    <ul class="tocnode"> <xsl:apply-templates select="documentNode[@nodeID]">
377        <xsl:with-param name="collName" select="$collName"/>
378        <xsl:with-param name="ec" select="$ec"/>
379        <xsl:with-param name="p.a" select="$p.a"/><xsl:with-param name="p.s" select="$p.s"/><xsl:with-param name="p.sa" select="$p.sa"/><xsl:with-param name="p.c" select="$p.c"/>
380        <!--<xsl:with-param name="depth" select="$depth + 1"/>-->
381      </xsl:apply-templates>
382    </ul>
383      </xsl:if>
384    </li>
385  </xsl:template>
386 
387  <!-- default content is to print the title and content of any documentNodes that have nodeContent -->
388  <xsl:template name="documentContent">
389    <div class="documenttext">
390      <xsl:choose>
391    <xsl:when test="@docType='simple'"><xsl:apply-templates select="nodeContent"/></xsl:when>
392    <xsl:otherwise>
393      <!--<xsl:apply-templates select="descendant-or-self::node()/documentNode" mode="content"/>-->
394    </xsl:otherwise>
395      </xsl:choose>
396    </div>
397  </xsl:template>
398 
399  <xsl:template match="documentNode" mode="content">
400    <xsl:if test="nodeContent">
401      <xsl:if test="metadataList/metadata[@name='Title']">
402    <h3><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></h3>
403      </xsl:if>
404      <xsl:apply-templates select="nodeContent"/>
405    </xsl:if>
406  </xsl:template>
407
408  <!-- the actual text/content -->
409  <xsl:template match="nodeContent">
410    <xsl:for-each select="node()">
411      <xsl:choose>
412    <xsl:when test="not(name())">
413      <xsl:value-of select="." disable-output-escaping="yes" />
414    </xsl:when>
415    <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
416      </xsl:choose>
417    </xsl:for-each>
418  </xsl:template>
419 
420  <xsl:template name="xmldocumentContentPeeling">
421    <xsl:choose>
422      <xsl:when test="@docType='simple'">
423    <xsl:apply-templates select="nodeContent"/>
424      </xsl:when>
425      <xsl:otherwise>
426    <xsl:call-template name="xmlpeelingContents" />
427      </xsl:otherwise>
428    </xsl:choose>
429  </xsl:template>
430 
431  <xsl:template name="xmlpeelingContents">
432    <xsl:if test="documentNode">
433      <xsl:apply-templates select="documentNode" mode="xmlpeeling" />
434    </xsl:if>
435  </xsl:template>
436
437  <xsl:template match="documentNode" mode="xmlpeeling">
438    <!-- get title -->
439    <xsl:choose>
440      <xsl:when test="nodeContent">
441    <xsl:text disable-output-escaping="yes">
442      &amp;lt;Section&amp;gt;
443      &amp;lt;Description&amp;gt;
444      &amp;lt;Metadata name="Title"&amp;gt;
445    </xsl:text>
446    <xsl:value-of select="normalize-space(metadataList/metadata[@name='Title'])"/>
447    <xsl:text disable-output-escaping="yes">
448      &amp;lt;/Metadata&amp;gt;
449      &amp;lt;/Description&amp;gt;
450    </xsl:text>
451    <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
452    <xsl:text disable-output-escaping="yes">&amp;lt;/Sec&amp;gt;</xsl:text>
453      </xsl:when>
454    </xsl:choose>
455
456    <!-- recurse to the children -->
457    <xsl:if test="documentNode">
458      <xsl:apply-templates select="documentNode" mode="xmlpeeling" />
459    </xsl:if>
460
461    <!-- end the section -->
462    <xsl:text disable-output-escaping="yes">
463      &amp;lt;/Section&amp;gt;
464    </xsl:text>
465  </xsl:template>
466 
467  <!-- match any file nodes -->
468  <xsl:template match="file">
469    <xsl:variable name="httpPath" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>
470    <xsl:choose>
471      <xsl:when test="starts-with(@mimeType, 'image/')">
472    <img src="{$httpPath}/{@href}"/>
473      </xsl:when>
474      <xsl:otherwise>
475    <a href="{$httpPath}/{@href}"><xsl:value-of select="@href"/></a>
476      </xsl:otherwise>
477    </xsl:choose>
478  </xsl:template>
479 
480  <!-- match any link nodes -->
481  <xsl:template match="link">
482    <xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
483    <xsl:variable name="actionargs">
484      <xsl:choose>
485    <xsl:when test="@type='document'">a=d</xsl:when>
486    <xsl:when test="@type='query'">a=q&amp;amp;s=<xsl:value-of select="@service"/>&amp;amp;rt=rd</xsl:when>
487    <xsl:otherwise>
488    p
489    </xsl:otherwise>
490      </xsl:choose>
491    </xsl:variable>
492    <xsl:variable name="serviceargs">
493      <xsl:for-each select="param">&amp;amp;s1.<xsl:value-of select="@name"/>=<xsl:value-of select="@value"/></xsl:for-each>
494    </xsl:variable>
495    <a href="{$library_name}?{$actionargs}&amp;amp;c={$collName}{$serviceargs}"><xsl:value-of disable-output-escaping="yes" select="."/></a>
496  </xsl:template>
497
498  <!-- match any annotations and make them span elements -->
499  <xsl:template match="annotation">
500    <span class="{@type}"><xsl:value-of disable-output-escaping="yes" select="."/></span>
501  </xsl:template>
502 
503  <!-- paged naviagtion : INCOMPLETE!!-->
504  <xsl:template name="pagedContents">
505    <xsl:param name="collName"/>
506    <xsl:variable name="pos" select="nodeStructureInfo/info[@name='siblingPosition']/@value"/>
507    <xsl:variable name="length" select="nodeStructureInfo/info[@name='numSiblings']/@value"/>
508    <xsl:variable name="children" select="nodeStructureInfo/info[@name='numChildren']/@value"/>
509    <table>
510      <xsl:choose>
511    <xsl:when test="$pos=-1"><!-- a doc -->
512      <tr valign="top">
513        <td align="left">
514        </td>
515        <td align="center"><center>
516        <b class="getTextFor doc.pages"></b>
517          </center></td>
518        <td align="right">
519          <a href="{$library_name}?a=d&amp;amp;c={$collName}&amp;amp;d={@selectedNode}.fc"><img src="interfaces/default/images/more.gif" border="0" align="absbottom" /></a>
520        </td>
521      </tr>
522    </xsl:when>
523   
524    <xsl:otherwise> <!-- an internal node -->     
525      <tr valign="top">
526        <td align="left">
527          <xsl:if test=" not ( $pos = 1 )">
528        <a href="{$library_name}?a=d&amp;amp;c={$collName}&amp;amp;d={@selectedNode}.ps"><img src="interfaces/default/images/less.gif" border="0" align="absbottom" /></a>
529          </xsl:if>
530        </td>
531        <td align="center"><center>
532        <b><xsl:attribute name="class"><xsl:value-of select="concat('getTextFor null this.innerText.doc.pageof|', $pos, ';', $length)"/></xsl:attribute></b>
533          </center></td>
534        <td align="right">
535          <xsl:if test=" not($pos = $length)">
536        <a href="{$library_name}?a=d&amp;amp;c={$collName}&amp;amp;d={@selectedNode}.ns"><img src="interfaces/default/images/more.gif" border="0" align="absbottom" /></a>
537          </xsl:if>
538        </td>
539      </tr>
540    </xsl:otherwise>
541      </xsl:choose>
542      <tr valign="middle">
543    <td align='center' valign='top' colspan='3'>
544      <form name="GotoForm" method="get" action="{$library_name}">
545        <input type='hidden' name='a' value='d'/>
546        <input type='hidden' name='c' value='{$collName}'/>
547        <input type='hidden' name='d' value='{@selectedNode}'/>
548        <input type="text" name="gp" size="3" maxlength="4"/>
549        <input type="submit" class="getTextFor null this.value.doc.gotopage"></input>
550      </form>
551    </td>
552      </tr>
553    </table>
554  </xsl:template>
555 
556  <xsl:template name="enrichServices">
557    <xsl:param name="collName"/>
558    <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
559    <xsl:variable name="request-params" select="/page/pageRequest/paramList"/>
560    <xsl:for-each select="../serviceList/service">
561      <table border='1' cellspacing='0'>
562    <tr><td>
563        <p /><xsl:value-of select="displayItem[@name='name']"/><p/>
564        <form name="EnrichForm" method="get" action="{$library_name}">
565          <xsl:apply-templates select="paramList"/>
566          <input type="hidden" name="a" value="d"/>
567          <input type="hidden" name="d" value="{$docID}"/>
568          <input type="hidden" name="c" value="{$collName}"/>
569          <xsl:if test="$request-params/param[@name='sib']">
570        <input type="hidden" name="sib"><xsl:attribute name="value"><xsl:value-of select="$request-params/param[@name='sib']/@value"/></xsl:attribute></input></xsl:if>
571          <input type="hidden" name="s" value="{@name}"/>
572          <input type="hidden" name="p.a"><xsl:attribute name="value"><xsl:value-of select="$request-params/param[@name='p.a']"/></xsl:attribute></input>
573          <input type="hidden" name="p.sa"><xsl:attribute name="value"><xsl:value-of select="$request-params/param[@name='p.sa']"/></xsl:attribute></input>
574          <input type="hidden" name="p.s"><xsl:attribute name="value"><xsl:value-of select="$request-params/param[@name='p.s']"/></xsl:attribute></input>
575          <input type="hidden" name="end" value='1'/>
576          <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input>
577        </form>
578      </td></tr>
579      </table>
580    </xsl:for-each>
581  </xsl:template>
582
583  <xsl:template match="paramList" mode="hidden">
584    <xsl:for-each select="param">
585      <input type='hidden' name='{@name}' value='{@value}'/><xsl:text>
586      </xsl:text>
587    </xsl:for-each>
588  </xsl:template>
589 
590  <xsl:template name="documentArrows">
591    <xsl:param name="collName"/>
592    <xsl:variable name="ed" select="/page/pageRequest/paramList/param[@name='ed']/@value"/>
593   
594    <div class="documentarrows">
595      <xsl:if test="not(string($ed)='1')">
596    <xsl:call-template name="documentArrow">
597      <xsl:with-param name="collName" select="$collName"/>
598      <xsl:with-param name="direction">back</xsl:with-param>
599    </xsl:call-template>
600    <xsl:call-template name="documentArrow">
601      <xsl:with-param name="collName" select="$collName"/>
602      <xsl:with-param name="direction">forward</xsl:with-param>
603    </xsl:call-template>
604      </xsl:if>
605    </div>
606   
607  </xsl:template>
608 
609  <xsl:template name="documentArrow">
610    <xsl:param name="collName"/>
611    <xsl:param name="direction"/>
612    <xsl:variable name="request-params" select="/page/pageRequest/paramList"/>
613    <xsl:if test="$request-params/param[@name='dt']/@value != 'simple'"> 
614      <a><xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;amp;c=<xsl:value-of select="$collName"/>&amp;amp;d=<xsl:value-of select="@selectedNode"/><xsl:choose><xsl:when test="$direction='back'">.pp</xsl:when><xsl:otherwise>.np</xsl:otherwise></xsl:choose>&amp;amp;sib=1&amp;amp;p.s=<xsl:value-of select="$request-params/param[@name='p.s']/@value"/>&amp;amp;p.sa=<xsl:value-of select="$request-params/param[@name='p.sa']/@value"/>&amp;amp;p.a=<xsl:value-of select="$request-params/param[@name='p.a']/@value"/></xsl:attribute><xsl:choose><xsl:when test="$direction='back'"><img class="lessarrow" src="interfaces/default/images/less.gif" /></xsl:when><xsl:otherwise><img class="morearrow" src="interfaces/default/images/more.gif"  /></xsl:otherwise></xsl:choose></a>
615    </xsl:if>
616  </xsl:template>
617
618  <xsl:template name="externalPage">
619    <xsl:param name="external"/>
620    <xsl:variable name="go_forward_link"><a class="getTextfor external.go_forward"><xsl:attribute name="href"><xsl:value-of select="$external"/></xsl:attribute></a></xsl:variable>
621    <h2 class="getTextFor external.title"></h2>
622    <p><xsl:attribute name="class"><xsl:value-of select="concat('getTextFor null this.innerText.external.text|', $go_forward_link)" /></xsl:attribute>
623    </p>
624  </xsl:template>
625
626</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.