source: trunk/gsdl3/web/interfaces/default/transform/classifier.xsl@ 4255

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

lots of changes but I dont remember what they are for

  • Property svn:keywords set to Author Date Id Revision
File size: 12.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 extension-element-prefixes="java">
6
7 <xsl:include href="style.xsl"/>
8
9 <xsl:output method="html"/>
10
11 <xsl:template name="pageHead">
12 <head>
13 <title><xsl:call-template name="text"><xsl:with-param name="key">gsdl</xsl:with-param></xsl:call-template></title>
14 </head>
15 </xsl:template>
16
17 <xsl:template match="pageResponse">
18 <xsl:variable name="collName"><xsl:value-of select="ancestor::page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
19 <xsl:variable name="serviceName"><xsl:value-of select="service/@name"/></xsl:variable>
20 <center>
21 <xsl:call-template name="collectionPageBanner">
22 <xsl:with-param name="collName" select="$collName"/>
23 </xsl:call-template>
24 <xsl:apply-templates select="service/classifierList">
25 <xsl:with-param name="collName" select="$collName"/>
26 <xsl:with-param name="serviceName" select="$serviceName"/>
27 </xsl:apply-templates>
28 <p/>
29 <xsl:apply-templates select="classifier">
30 <xsl:with-param name="collName" select="$collName"/>
31 <xsl:with-param name="serviceName" select="$serviceName"/>
32 </xsl:apply-templates>
33 </center>
34 </xsl:template>
35
36 <xsl:template match="classifierList">
37 <xsl:param name="collName"/>
38 <xsl:param name="serviceName"/>
39 <xsl:variable name="library" select="ancestor::page/pageExtra/config/library_name"/>
40 <xsl:variable name="selected" select="ancestor::page/pageResponse/classifier/@name"/>
41 <table width='537'><tr>
42 <xsl:for-each select="classifier">
43 <xsl:variable name="cname" select="@name"/>
44 <xsl:choose>
45 <xsl:when test="@name=$selected">
46 <td align='center'><xsl:value-of select="ancestor::service/display/classifier[@name=$cname]/name"/></td>
47 </xsl:when>
48 <xsl:otherwise>
49 <td align='center'><a href="{$library}?a=b&amp;rt=r&amp;s={$serviceName}&amp;c={$collName}&amp;cl={@name}"><xsl:value-of select="ancestor::service/display/classifier[@name=$cname]/name"/></a></td></xsl:otherwise></xsl:choose>
50 </xsl:for-each>
51 </tr></table>
52 <xsl:call-template name="greenBar"/>
53 </xsl:template>
54
55 <!-- recursively process all nodes and documents -->
56
57 <xsl:template match="classifier">
58 <xsl:param name="collName"/>
59 <xsl:param name="serviceName"/>
60 <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
61 <xsl:variable name="interleave"><xsl:value-of select="ancestor::page/pageResponse/service/classifierList/classifier[@name=$cl_name]/@documentInterleave"/></xsl:variable>
62 <xsl:variable name="orientation"><xsl:value-of select="ancestor::page/pageResponse/service/classifierList/classifier[@name=$cl_name]/@orientation"/></xsl:variable>
63 <xsl:variable name='mode'><xsl:value-of select='$orientation'/>-<xsl:value-of select='$interleave'/></xsl:variable>
64 <!-- cant seem to do this any other way, ie mode='{$mode}' doesn't work -->
65 <xsl:choose>
66 <xsl:when test="$mode='horizontal-true'">
67 <xsl:apply-templates select="." mode='horizontal-true'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
68 </xsl:when>
69 <xsl:when test="$mode='horizontal-false'">
70 <xsl:apply-templates select="." mode='horizontal-false'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
71 </xsl:when>
72 <xsl:when test="$mode='vertical-true'">
73 <xsl:apply-templates select="." mode='vertical-true'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
74 </xsl:when>
75 <xsl:when test="$mode='vertical-false'">
76 <xsl:apply-templates select="." mode='vertical-false'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
77 </xsl:when>
78 </xsl:choose>
79 </xsl:template>
80
81 <!-- vertical and interleave = true: process all document and classifier children together, recursively -->
82 <xsl:template match="classifier" mode="vertical-true">
83 <xsl:param name="collName"/>
84 <xsl:param name="serviceName"/>
85 <table width='537'>
86 <xsl:for-each select='classifierNode|documentNode'>
87 <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
88 <xsl:if test='name()="classifierNode"'>
89 <!--recurse into the children-->
90 <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-all-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
91 </xsl:if>
92 </xsl:for-each>
93 </table>
94 <xsl:call-template name="greenBar"/>
95 </xsl:template>
96
97 <!--vertical and interleave = false: process all classifier nodes, recursively, then do the document ones separately -->
98 <xsl:template match="classifier" mode="vertical-false">
99 <xsl:param name="collName"/>
100 <xsl:param name="serviceName"/>
101 <!-- process the nodes and documents separately-->
102 <table width='537'>
103 <xsl:for-each select='classifierNode'>
104 <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
105 <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr></xsl:for-each>
106 </table>
107 <table width='537'>
108 <xsl:for-each select='//documentNode'>
109 <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
110 </xsl:for-each>
111 </table>
112 <xsl:call-template name="greenBar"/>
113 </xsl:template>
114
115
116 <xsl:template match="classifier" mode="horizontal-true">
117 <xsl:param name="collName"/>
118 <xsl:param name="serviceName"/>
119 <!-- process the nodes and documents together -->
120
121 <table>
122 <tr valign='top'>
123 <xsl:for-each select='classifierNode|documentNode'>
124 <xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
125 </xsl:for-each>
126 </tr>
127 <tr valign='top'>
128 <xsl:for-each select='classifierNode|documentNode'>
129 <td><xsl:text> </xsl:text></td> <!-- the empty cell for the icon -->
130 <xsl:choose><xsl:when test='name()="classifierNode" and classifierNode|documentNode'>
131 <xsl:apply-templates select='.' mode='process-all-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
132 </xsl:when>
133 <xsl:otherwise>
134 <td><xsl:text> </xsl:text></td>
135 </xsl:otherwise>
136 </xsl:choose>
137 </xsl:for-each>
138 </tr>
139 </table>
140 <xsl:call-template name="greenBar"/>
141 </xsl:template>
142
143 <xsl:template match="classifier" mode="horizontal-false">
144 <xsl:param name="collName"/>
145 <xsl:param name="serviceName"/>
146 <!-- process the nodes and documents separately-->
147
148 <table width='537'><tr valign='top'>
149 <xsl:for-each select='classifierNode'>
150 <xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
151 </xsl:for-each></tr>
152 <tr valign='top'>
153 <xsl:for-each select='classifierNode'>
154 <xsl:apply-templates select='.' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></xsl:for-each></tr>
155 </table>
156 <table width='537'>
157 <xsl:for-each select='//documentNode'>
158 <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
159 </xsl:for-each>
160 </table>
161 <xsl:call-template name="greenBar"/>
162 </xsl:template>
163
164 <!-- default doc node template: icon and title -->
165 <xsl:template match="documentNode">
166 <xsl:param name="collName"/>
167 <xsl:variable name='library' select='ancestor::page/pageExtra/config/library_name'/>
168 <td><a href="{$library}?a=d&amp;c={$collName}&amp;d={@nodeID}"><xsl:apply-templates select="." mode="displayNodeIcon"/></a></td><td><xsl:value-of select="metadataList/metadata[@name='Title']"/></td>
169 </xsl:template>
170
171 <!-- default classifier node template: icon + title -->
172 <xsl:template match="classifierNode">
173 <xsl:param name="collName"/>
174 <xsl:param name="serviceName"/>
175 <xsl:variable name="library" select="ancestor::page/pageExtra/config/library_name"/>
176 <td><a><xsl:attribute name='href'><xsl:value-of select='$library'/>?a=b&amp;rt=r&amp;s=<xsl:value-of select='$serviceName'/>&amp;c=<xsl:value-of select='$collName'/>&amp;cl=<xsl:value-of select='@nodeID'/><xsl:if test="classifierNode|documentNode">.pr</xsl:if></xsl:attribute><img src='interfaces/default/images/bshelf.gif' border='0' width='20' height='16' /></a></td><td align='left'><xsl:value-of select="metadataList/metadata[@name='Title']"/></td>
177 </xsl:template>
178
179 <!-- an alternative classifier node template: the title is a link -->
180 <!--
181 <xsl:template match="classifierNode">
182 <xsl:param name="collName"/>
183 <xsl:param name="serviceName"/>
184 <xsl:variable name="library" select="ancestor::page/pageExtra/config/library_name"/>
185 <td><a><xsl:attribute name='href'><xsl:value-of select='$library'/>?a=b&amp;rt=r&amp;s=<xsl:value-of select='$serviceName'/>&amp;c=<xsl:value-of select='$collName'/>&amp;cl=<xsl:value-of select='@nodeID'/><xsl:if test="classifierNode|documentNode">.pr</xsl:if></xsl:attribute><xsl:value-of select="metadataList/metadata[@name='Title']"/></a></td>
186 </xsl:template>
187 -->
188
189<!-- processing for the recursive bit -->
190<!-- if interleave=true, process all child nodes and documents, else just do nodes -->
191
192 <xsl:template match="classifierNode" mode="process-all-children">
193 <xsl:param name="collName"/>
194 <xsl:param name="serviceName"/>
195 <td><p/>
196 <!-- only do this if there are children -->
197 <xsl:if test="classifierNode|documentNode">
198 <xsl:choose>
199 <xsl:when test='@orientation="vertical"'>
200 <table>
201 <xsl:for-each select='classifierNode|documentNode'>
202 <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
203 <xsl:if test='name()="classifierNode"'>
204 <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-all-children'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
205 </xsl:if>
206 </xsl:for-each>
207 </table>
208 </xsl:when>
209 <xsl:otherwise> <!-- horizontal -->
210 <table>
211 <tr valign='top'>
212 <xsl:for-each select='classifierNode|documentNode'>
213 <xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
214 <xsl:if test='name()="classifierNode"'>
215 <xsl:apply-templates select='.' mode='process-all-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
216 </xsl:if>
217 </xsl:for-each>
218 </tr>
219 </table>
220 </xsl:otherwise>
221 </xsl:choose>
222 </xsl:if>
223 </td>
224 </xsl:template>
225
226 <xsl:template match="classifierNode" mode="process-node-children">
227 <xsl:param name="collName"/>
228 <xsl:param name="serviceName"/>
229 <td><p/>
230 <xsl:if test='classifierNode'><!-- only do this if there are child nodes - netscape craps out at an empty table like <table /> -->
231 <xsl:choose>
232 <xsl:when test='@orientation="vertical"'>
233 <table>
234 <xsl:for-each select='classifierNode'>
235 <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
236 <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
237 </xsl:for-each>
238 </table>
239 </xsl:when>
240 <xsl:otherwise>
241 <table>
242 <tr valign='top'><xsl:apply-templates select='classifierNode'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
243 <xsl:apply-templates select='classifierNode' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
244 </table>
245 </xsl:otherwise>
246 </xsl:choose>
247 </xsl:if>
248 </td>
249 </xsl:template>
250
251</xsl:stylesheet>
252
253
254
255
256
257
Note: See TracBrowser for help on using the repository browser.