root/main/branches/64_bit_Greenstone/greenstone3/web/interfaces/default/transform/classifiertools.xsl @ 24007

Revision 24007, 7.0 KB (checked in by sjm84, 8 years ago)

Updating this branch to match the latest Greenstone3 changes

  • Property svn:keywords set to Author Date Id Revision
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  exclude-result-prefixes="java">
7 
8  <xsl:template match="classifier">
9    <xsl:param name="collName"/>
10    <xsl:param name="serviceName"/>
11    <div id="classifiers">
12      <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
13      <xsl:choose>
14    <xsl:when test="/page/pageResponse/service/classifierList/classifier[@name=$cl_name]/@horizontalAtTop">
15      <xsl:apply-templates select="." mode="horizontal-at-top">
16        <xsl:with-param name="collName" select="$collName"/>
17        <xsl:with-param name="serviceName" select="$serviceName"/>
18      </xsl:apply-templates>
19    </xsl:when>
20    <xsl:otherwise>
21      <xsl:apply-templates select="." mode="default">
22        <xsl:with-param name="collName" select="$collName"/>
23        <xsl:with-param name="serviceName" select="$serviceName"/>
24      </xsl:apply-templates>
25    </xsl:otherwise>
26      </xsl:choose>
27    </div>
28  </xsl:template>
29 
30
31  <xsl:template match="classifier" mode="horizontal-at-top">
32    <xsl:param name="collName"/>
33    <xsl:param name="serviceName"/>
34    <xsl:choose>
35      <xsl:when test="classifierNode">
36    <ul id="classifiernodelist-horizontal">
37      <xsl:for-each select='classifierNode'>
38        <xsl:apply-templates select='.' mode="horizontal"><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
39      </xsl:for-each>
40    </ul>
41    <ul id="childrenlist">
42      <li>
43            <table><tr>
44        <xsl:for-each select='classifierNode'>
45          <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>
46        </xsl:for-each>
47          </tr></table>
48      </li>
49    </ul>
50      </xsl:when>
51      <xsl:otherwise>
52    <!-- there were no classifier nodes -->
53    <ul id="childrenlist">
54          <xsl:for-each select='documentNode'>
55        <li><table><tr><xsl:call-template name="documentNodeWrapper">
56            <xsl:with-param name='collName' select='$collName'/>
57            <xsl:with-param name='serviceName' select='$serviceName'/>
58          </xsl:call-template></tr></table></li>
59      </xsl:for-each>
60    </ul>
61      </xsl:otherwise>
62    </xsl:choose>
63  </xsl:template>
64
65  <xsl:template match="classifier" mode="default"> <!-- the default -->
66    <xsl:param name="collName"/>
67    <xsl:param name="serviceName"/>
68    <ul id="classifiernodelist">
69      <xsl:call-template name="processNodeChildren">
70    <xsl:with-param name='collName' select='$collName'/>
71    <xsl:with-param name='serviceName' select='$serviceName'/>
72      </xsl:call-template>
73    </ul>
74  </xsl:template>
75 
76  <!-- 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 -->
77  <xsl:template name="documentNodeWrapper">
78    <xsl:param name="collName"/>
79    <xsl:param name="serviceName"/>
80    <xsl:variable name="berrybasketswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:variable>
81    <!--<xsl:if test="$berryBaskets = 'true'">-->
82    <xsl:if test="$berrybasketswitch = 'on'">
83      <xsl:call-template name="addBerry">
84    <xsl:with-param name="collName" select="$collName"/>
85      </xsl:call-template>
86    </xsl:if>
87    <xsl:apply-templates select=".">
88      <xsl:with-param name="collName" select="$collName"/>
89      <xsl:with-param name="serviceName" select="$serviceName"/>
90    </xsl:apply-templates>
91  </xsl:template>
92
93  <xsl:template match="documentNode">
94    <xsl:param name="collName"/>
95    <xsl:param name="serviceName"/>
96    <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:text>Test</xsl:text><xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/>
97  </xsl:template>
98
99 
100 
101  <!-- icon + title template-->
102  <xsl:template match="classifierNode">
103    <xsl:param name="collName"/>
104    <xsl:param name="serviceName"/>
105    <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']"/>
106
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.