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

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

fixed up some of the hard coded text strings, added the goto page form for paged documents

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