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

Last change on this file since 4731 was 4712, checked in by kjdon, 21 years ago

made a lot of changes, cant remember tham all. config stuff is now global params, translate stuff is now done on the fly using java and XSLTUtil, redoing the document display stuff so that it switches automatically between toc, page nav, and just displaying the text

  • Property svn:keywords set to Author Date Id Revision
File size: 9.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 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <xsl:include href="style.xsl"/>
10 <xsl:include href="service-params.xsl"/>
11 <xsl:output method="html"/>
12 <!--
13 <xsl:output method="xml"/>
14 -->
15
16 <xsl:template name="pageHead">
17 <xsl:variable name="docID" select="/page/pageResponse/document/@selectedNode"/>
18 <head>
19 <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></title>
20 <xsl:call-template name="css-style"/>
21 </head>
22 </xsl:template>
23
24 <!-- this is hard coded for GATE, should somehow do it dynamically-->
25 <xsl:template name="css-style">
26 <style type="text/css">
27 <xsl:text disable-output-escaping="yes">
28 span.Location { display:inline; color : red }
29 span.Person { display:inline; color : green }
30 span.Organization { display:inline; color : yellow }
31 span.Date { display:inline; color : blue }
32 span.query_term {display: inline; background-color : yellow }
33 </xsl:text>
34 </style>
35 </xsl:template>
36
37 <xsl:template match="pageResponse">
38 <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
39 <center>
40 <xsl:call-template name="collectionPageBanner">
41 <xsl:with-param name="collName" select="$collName"/>
42 </xsl:call-template>
43
44 <!-- display the document -->
45 <xsl:apply-templates select="document">
46 <xsl:with-param name="collName" select="$collName"/>
47 </xsl:apply-templates>
48 </center>
49
50 <xsl:call-template name="greenBar"/>
51 </xsl:template>
52
53 <xsl:template match="document">
54 <xsl:param name="collName"/>
55 <p/>
56 <xsl:call-template name="documentHeading">
57 <xsl:with-param name="collName" select="$collName"/>
58 </xsl:call-template>
59 <p/>
60 <xsl:call-template name="documentContent">
61 <xsl:with-param name="collName" select="$collName"/>
62 </xsl:call-template>
63 </xsl:template>
64
65 <!-- hierarchical document -->
66 <xsl:template name="documentHeading">
67 <xsl:param name="collName"/>
68 <table width="537" cellpadding="0" cellspacing="0">
69 <tr>
70 <td valign="top" align="left" width="200">
71 <xsl:call-template name="coverImage"/>
72 <p/>
73 <xsl:call-template name="enrichServices">
74 <xsl:with-param name="collName" select="$collName"/>
75 </xsl:call-template>
76 </td>
77 <td valign="top">
78 <xsl:call-template name="TOC">
79 <xsl:with-param name="collName" select="$collName"/>
80 </xsl:call-template>
81 </td>
82 </tr>
83 </table>
84 </xsl:template>
85
86 <xsl:template name="coverImage">
87 <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>
88 </xsl:template>
89
90 <xsl:template name="TOC">
91 <xsl:param name="collName"/>
92 <xsl:choose>
93 <xsl:when test="@documentType='hierarchy'">
94 <xsl:call-template name="hierarchicalContents">
95 <xsl:with-param name="collName" select="$collName"/>
96 </xsl:call-template>
97 </xsl:when>
98 <xsl:when test="@documentType='paged'">
99 <xsl:call-template name="pagedContents">
100 <xsl:with-param name="collName" select="$collName"/>
101 </xsl:call-template>
102 </xsl:when>
103 <xsl:otherwise>
104 <!-- just print the title of teh one and only docNode -->
105 <xsl:value-of select="documentNode/metadataList/metadata[@name='Title']"/>
106 </xsl:otherwise>
107 </xsl:choose>
108 </xsl:template>
109
110 <xsl:template name="hierarchicalContents">
111 <xsl:param name="collName"/>
112 <xsl:apply-templates select="documentNode[@nodeID]">
113 <xsl:with-param name="collName" select="$collName"/>
114 <xsl:with-param name="depth" select="0"/>
115 </xsl:apply-templates>
116 </xsl:template>
117
118 <xsl:template match="documentNode">
119 <xsl:param name="collName"/>
120 <xsl:param name="depth"/>
121 <xsl:variable name="space" select="$depth * 25"/>
122
123 <table>
124 <tr valign="top">
125 <td>
126 <xsl:if test="not($depth = '0')">
127 <img src="interfaces/default/images/space.gif" width="{$space}"/>
128 </xsl:if>
129 </td>
130
131 <!-- Display the appropriate image, depending on the node type -->
132 <td valign="top">
133 <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:attribute>
134 <xsl:apply-templates select="." mode="displayNodeIcon"/>
135 </a>
136 </td>
137
138 <!-- Display associated title, bolded if the node has content -->
139 <td valign="top">
140 <xsl:choose>
141 <xsl:when test="nodeContent">
142 <b><xsl:value-of select="metadataList/metadata[@name='Title']"/></b>
143 </xsl:when>
144 <xsl:otherwise>
145 <xsl:value-of select="metadataList/metadata[@name='Title']"/>
146 </xsl:otherwise>
147 </xsl:choose>
148 </td>
149 </tr>
150 </table>
151 <!-- Apply recursively to the children of this node -->
152 <xsl:apply-templates select="documentNode[@nodeID]">
153 <xsl:with-param name="collName" select="$collName"/>
154 <xsl:with-param name="depth" select="$depth + 1"/>
155 </xsl:apply-templates>
156 </xsl:template>
157
158
159 <!-- default content is to process any nodeContent elements and print out their text -->
160 <xsl:template name="documentContent">
161 <xsl:apply-templates select="descendant::documentNode/nodeContent"/>
162 </xsl:template>
163
164
165 <!-- the actual text/content -->
166 <xsl:template match="nodeContent">
167 <p/>
168 <table width="537" cellpadding="0" cellspacing="0">
169 <tr>
170 <td align="left">
171 <xsl:for-each select="node()">
172 <xsl:choose>
173 <xsl:when test="not(name())"><xsl:value-of select="." disable-output-escaping="yes"/></xsl:when>
174 <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
175 </xsl:choose>
176 </xsl:for-each>
177 </td>
178 </tr>
179 </table>
180 </xsl:template>
181
182 <!-- match any annotations and make them span elements -->
183 <xsl:template match="annotation">
184 <span class="{@type}"><xsl:value-of disable-output-escaping="yes" select="."/></span>
185 </xsl:template>
186
187
188
189 <!-- paged naviagtion : INCOMPLETE!!-->
190 <xsl:template name="pagedContents">
191 <xsl:param name="collName"/>
192 <xsl:variable name="pos" select="nodeStructureInfo/info[@name='siblingPosition']/@value"/>
193 <xsl:variable name="length" select="nodeStructureInfo/info[@name='numSiblings']/@value"/>
194 <xsl:variable name="children" select="nodeStructureInfo/info[@name='numChildren']/@value"/>
195 <table>
196 <xsl:choose>
197 <xsl:when test="$pos=-1"><!-- a doc -->
198 <tr valign="top">
199 <td align="left">
200 </td>
201 <td align="center"><center>
202 <b><xsl:value-of select="$children"/> pages.</b>
203 </center></td>
204 <td align="right">
205 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@selectedNode}.fc"><img src="interfaces/nzdl/images/more.gif" border="0" align="absbottom" /></a>
206 </td>
207 </tr>
208 </xsl:when>
209
210 <xsl:otherwise> <!-- an internal node -->
211 <tr valign="top">
212 <td align="left">
213 <xsl:if test=" not ( $pos = 1 )">
214 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@selectedNode}.ps"><img src="interfaces/nzdl/images/less.gif" border="0" align="absbottom" /></a>
215 </xsl:if>
216 </td>
217 <td align="center"><center>
218 <b>Page <xsl:value-of select="$pos"/> of <xsl:value-of select="$length"/>.</b>
219 </center></td>
220 <td align="right">
221 <xsl:if test=" not($pos = $length)">
222 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@selectedNode}.ns"><img src="interfaces/nzdl/images/more.gif" border="0" align="absbottom" /></a>
223 </xsl:if>
224 </td>
225 </tr>
226 </xsl:otherwise>
227 </xsl:choose>
228 <tr valign="middle">
229 <td align='center' valign='top' colspan='3'> goto form
230 </td>
231 </tr>
232 </table>
233 </xsl:template>
234
235 <xsl:template name="enrichServices">
236 <xsl:param name="collName"/>
237 <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
238 <xsl:for-each select="../serviceList/service">
239 <table border='1' cellspacing='0'>
240 <tr><td>
241 <p /><xsl:value-of select="display/name"/><p/>
242 <form name="EnrichForm" method="get" action="/gsdl3/{$library_name}">
243 <xsl:apply-templates select="paramList"/>
244 <input type='hidden' name='a' value='d'/>
245 <input type='hidden' name='d' value='{$docID}'/>
246 <input type='hidden' name='c' value='{$collName}'/>
247 <xsl:if test='/page/pageRequest/paramList/param[@name="sib"]'>
248 <input type='hidden' name='sib'><xsl:attribute name='value'><xsl:value-of select='/page/pageRequest/paramList/param[@name="sib"]/@value'/></xsl:attribute></input></xsl:if>
249 <input type='hidden' name='s' value='{@name}'/>
250 <input type="submit"><xsl:attribute name="value"><xsl:value-of select='display/submit'/></xsl:attribute></input>
251 </form>
252 </td></tr>
253 </table>
254 </xsl:for-each>
255 </xsl:template>
256
257 <xsl:template match="paramList" mode="hidden">
258 <xsl:for-each select="param">
259 <input type='hidden' name='{@name}' value='{@value}'/><xsl:text>
260 </xsl:text>
261 </xsl:for-each>
262 </xsl:template>
263
264 <xsl:template match="paramList">
265 <p/><table>
266 <xsl:for-each select="param">
267 <xsl:choose>
268 <xsl:when test="@type='multi'">
269 <tr><td colspan='2'>
270 <xsl:apply-templates select='.'/></td></tr>
271 </xsl:when>
272 <xsl:otherwise>
273 <xsl:variable name="pname" select="@name"/>
274 <tr><td><xsl:value-of select='ancestor::service/display/param[@name=$pname]/name'/></td><td align="right"><xsl:apply-templates select="."/></td></tr>
275 </xsl:otherwise>
276 </xsl:choose>
277 </xsl:for-each>
278 </table>
279 </xsl:template>
280
281</xsl:stylesheet>
282
283
284
285
Note: See TracBrowser for help on using the repository browser.