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

Revision 23972, 7.0 KB (checked in by sjm84, 8 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  extension-element-prefixes="java util"
7  exclude-result-prefixes="java util">
8 
9  <xsl:template match="classifier">
10    <xsl:param name="collName"/>
11    <xsl:param name="serviceName"/>
12    <div id="classifiers">
13      <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
14      <xsl:choose>
15    <xsl:when test="/page/pageResponse/service/classifierList/classifier[@name=$cl_name]/@horizontalAtTop">
16      <xsl:apply-templates select="." mode="horizontal-at-top">
17        <xsl:with-param name="collName" select="$collName"/>
18        <xsl:with-param name="serviceName" select="$serviceName"/>
19      </xsl:apply-templates>
20    </xsl:when>
21    <xsl:otherwise>
22      <xsl:apply-templates select="." mode="default">
23        <xsl:with-param name="collName" select="$collName"/>
24        <xsl:with-param name="serviceName" select="$serviceName"/>
25      </xsl:apply-templates>
26    </xsl:otherwise>
27      </xsl:choose>
28    </div>
29  </xsl:template>
30 
31
32  <xsl:template match="classifier" mode="horizontal-at-top">
33    <xsl:param name="collName"/>
34    <xsl:param name="serviceName"/>
35    <xsl:choose>
36      <xsl:when test="classifierNode">
37    <ul id="classifiernodelist-horizontal">
38      <xsl:for-each select='classifierNode'>
39        <xsl:apply-templates select='.' mode="horizontal"><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
40      </xsl:for-each>
41    </ul>
42    <ul id="childrenlist">
43      <li>
44            <table><tr>
45        <xsl:for-each select='classifierNode'>
46          <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>
47        </xsl:for-each>
48          </tr></table>
49      </li>
50    </ul>
51      </xsl:when>
52      <xsl:otherwise>
53    <!-- there were no classifier nodes -->
54    <ul id="childrenlist">
55          <xsl:for-each select='documentNode'>
56        <li><table><tr><xsl:call-template name="documentNodeWrapper">
57            <xsl:with-param name='collName' select='$collName'/>
58            <xsl:with-param name='serviceName' select='$serviceName'/>
59          </xsl:call-template></tr></table></li>
60      </xsl:for-each>
61    </ul>
62      </xsl:otherwise>
63    </xsl:choose>
64  </xsl:template>
65
66  <xsl:template match="classifier" mode="default"> <!-- the default -->
67    <xsl:param name="collName"/>
68    <xsl:param name="serviceName"/>
69    <ul id="classifiernodelist">
70      <xsl:call-template name="processNodeChildren">
71    <xsl:with-param name='collName' select='$collName'/>
72    <xsl:with-param name='serviceName' select='$serviceName'/>
73      </xsl:call-template>
74    </ul>
75  </xsl:template>
76 
77  <!-- this is a wrapper node, which the interface can use to add stuff into the query results that isn't part of and doesn't depend on the documentNode template which may come from the collection -->
78  <xsl:template name="documentNodeWrapper">
79    <xsl:param name="collName"/>
80    <xsl:param name="serviceName"/>
81    <xsl:variable name="berrybasketswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:variable>
82    <!--<xsl:if test="$berryBaskets = 'true'">-->
83    <xsl:if test="$berrybasketswitch = 'on'">
84      <xsl:call-template name="addBerry">
85    <xsl:with-param name="collName" select="$collName"/>
86      </xsl:call-template>
87    </xsl:if>
88    <xsl:apply-templates select=".">
89      <xsl:with-param name="collName" select="$collName"/>
90      <xsl:with-param name="serviceName" select="$serviceName"/>
91    </xsl:apply-templates>
92  </xsl:template>
93
94  <xsl:template match="documentNode">
95    <xsl:param name="collName"/>
96    <xsl:param name="serviceName"/>
97    <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@nodeID}&amp;dt={@docType}&amp;p.a=b&amp;p.s={$serviceName}"><xsl:apply-templates select="." mode="displayNodeIcon"/></a><xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/>
98  </xsl:template>
99
100 
101 
102  <!-- icon + title template-->
103  <xsl:template match="classifierNode">
104    <xsl:param name="collName"/>
105    <xsl:param name="serviceName"/>
106    <a><xsl:attribute name='href'><xsl:value-of select='$library_name'/>?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:call-template name="bookshelfimg"/></a><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
107  </xsl:template>
108 
109  <!-- the title is a link: an alternative template -->
110  <xsl:template match="classifierNode" mode="horizontal">
111    <xsl:param name="collName"/>
112    <xsl:param name="serviceName"/>
113    <li><xsl:choose>
114    <xsl:when test="classifierNode|documentNode"><b><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/><xsl:text> </xsl:text></b></xsl:when>
115    <xsl:otherwise>
116      <a><xsl:attribute name='href'><xsl:value-of select='$library_name'/>?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:attribute><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></a><xsl:text> </xsl:text></xsl:otherwise>
117      </xsl:choose>
118    </li>
119  </xsl:template>
120 
121
122  <!-- processing for the recursive bit -->
123  <xsl:template match="classifierNode" mode="process-all-children">
124    <xsl:param name="collName"/>
125    <xsl:param name="serviceName"/>
126    <xsl:call-template name="processNodeChildren">
127      <xsl:with-param name='collName' select='$collName'/>
128      <xsl:with-param name='serviceName' select='$serviceName'/>
129    </xsl:call-template>
130  </xsl:template>
131 
132  <xsl:template name="processNodeChildren">
133    <xsl:param name="collName"/>
134    <xsl:param name="serviceName"/>
135    <xsl:for-each select='classifierNode|documentNode'>
136      <xsl:choose><xsl:when test="name()='documentNode'">
137      <li><table><tr>
138        <xsl:call-template name="documentNodeWrapper">
139          <xsl:with-param name='collName' select='$collName'/>
140          <xsl:with-param name='serviceName' select='$serviceName'/>
141        </xsl:call-template>
142          </tr></table>
143      </li>
144    </xsl:when>
145    <xsl:otherwise>
146      <li><table><tr>
147        <xsl:apply-templates select='.'>
148          <xsl:with-param name='collName' select='$collName'/>
149          <xsl:with-param name='serviceName' select='$serviceName'/>
150        </xsl:apply-templates>
151          </tr></table>
152      </li>
153      <xsl:if test="child::classifierNode or child::documentNode">
154        <!--recurse into the children-->
155        <li><ul class="childrenlist">
156        <xsl:apply-templates select='.' mode='process-all-children'>
157          <xsl:with-param name='collName' select='$collName'/>
158          <xsl:with-param name='serviceName' select='$serviceName'/>
159        </xsl:apply-templates>
160          </ul>
161        </li>
162      </xsl:if>
163    </xsl:otherwise>
164      </xsl:choose>
165    </xsl:for-each>
166  </xsl:template>
167</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.