root/main/trunk/greenstone3/web/interfaces/default-client-xslt/transform/document.xsl @ 23972

Revision 23972, 30.1 KB (checked in by sjm84, 9 years ago)

Moving traditional to default-client-xslt

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