source: main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl@ 26100

Last change on this file since 26100 was 26100, checked in by ak19, 12 years ago

Hierarchical documentNodes that are rootnotes need to be designated with a book icon instead of a page icon. This also needs to work for GS3 for the tutorial Enhanced Word document handling.

File size: 13.4 KB
RevLine 
[19860]1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
[24115]3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:xslt="output.xsl"
5 xmlns:java="http://xml.apache.org/xslt/java"
6 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
7 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
8 extension-element-prefixes="java">
[24458]9 <xsl:param name="interface_name"/>
10 <xsl:param name="library_name"/>
[19860]11
[24115]12 <xsl:output method="xml"/>
13 <xsl:namespace-alias stylesheet-prefix="xslt" result-prefix="xsl"/>
[19860]14
[24115]15 <xsl:template match="format">
16 <format>
17 <xsl:apply-templates/>
18 </format>
19 </xsl:template>
[19860]20
[24115]21 <xsl:template match="gsf:template">
22 <xslt:template>
23 <xsl:copy-of select="@*"/>
24 <xsl:attribute name="priority">2</xsl:attribute>
25 <xsl:if test=".//gsf:link">
26 <xslt:param name="serviceName"/>
27 <xslt:param name="collName"/>
28 </xsl:if>
29 <xsl:apply-templates/>
30 </xslt:template>
31 </xsl:template>
[24458]32
33 <xsl:template match="gsf:variable">
34 <xslt:variable>
35 <xsl:copy-of select="@*"/>
36 <xsl:apply-templates/>
37 </xslt:variable>
38 <script type="text/javascript">
39 gs.variables.<xsl:value-of select="@name"/><xslt:text disable-output-escaping="yes"> = "</xslt:text><xsl:apply-templates/><xslt:text disable-output-escaping="yes">";</xslt:text>
40 </script>
41 </xsl:template>
[24792]42
43 <xsl:template match="gsf:defaultClassifierNode">
44 <xslt:call-template name="defaultClassifierNode"/>
45 </xsl:template>
[25002]46
47 <xsl:template match="gsf:image">
[26022]48 <xslt:variable name="metaName">
[26020]49 <xsl:choose>
50 <xsl:when test="@type = 'thumb'">Thumb</xsl:when>
51 <xsl:when test="@type = 'screen'">Screen</xsl:when>
52 <xsl:when test="@type = 'source'">SourceFile</xsl:when>
53 </xsl:choose>
[26022]54 </xslt:variable>
55 <xslt:if test="(.//metadataList)[last()]/metadata[@name = $metaName]">
[26020]56 <img>
57 <xslt:attribute name='src'>
58 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
59 <xsl:text>/index/assoc/</xsl:text>
60 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name = 'assocfilepath']"/>
61 <xsl:text>/</xsl:text>
[26022]62 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = $metaName]"/>
[26020]63 </xslt:attribute>
64 </img>
[26022]65 </xslt:if>
[25002]66 </xsl:template>
67
[24115]68 <xsl:template match="gsf:link">
69 <xsl:choose>
70 <xsl:when test="@type='classifier'">
71 <a>
72 <xslt:attribute name='href'>
73 <xslt:value-of select='$library_name'/>
[25438]74 <xsl:text>/collection/</xsl:text>
[24115]75 <xslt:value-of select='/page/pageResponse/collection/@name'/>
[25438]76 <xsl:text>/browse/</xsl:text>
77 <xslt:value-of select='util:replace(@nodeID, ".", "/")'/>
[24115]78 </xslt:attribute>
79 <xsl:apply-templates/>
80 </a>
81 </xsl:when>
[24127]82 <xsl:when test="@type='source'">
83 <a><xslt:attribute name='href'><xslt:value-of
84 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
[25177]85 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='assocfilepath']" />/<xslt:value-of
86 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='srclinkFile']" /></xslt:attribute>
[24127]87 <xsl:apply-templates/>
88 </a>
89 </xsl:when>
[26043]90 <xsl:when test="@type='web'">
91 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, 'weblink')]"/>
92 <xsl:apply-templates/>
93 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, '/weblink')]"/>
94 </xsl:when>
95 <xsl:when test="@type='equivdoc'">
96 <xsl:call-template name="gsf:equivlinkgs3"/>
97 </xsl:when>
[24115]98 <xsl:otherwise> <!-- a document link -->
99 <xslt:variable name="bookswitch">
100 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
101 </xslt:variable>
[25361]102 <a>
103 <xslt:attribute name="href">
104 <xslt:value-of select='$library_name'/>
105 <xsl:text>/collection/</xsl:text>
106 <xslt:value-of select='/page/pageResponse/collection/@name'/>
107 <xsl:text>/document/</xsl:text>
108 <xslt:value-of select='@nodeID'/>
[25919]109 <xslt:choose>
110 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
111 <xsl:text>?book=on</xsl:text>
112 </xslt:when>
113 <xslt:otherwise>
114 <xslt:if test="$opt-doc-link-args">?<xslt:value-of select="$opt-doc-link-args"/></xslt:if>
115 </xslt:otherwise>
116 </xslt:choose>
[25361]117 </xslt:attribute>
118 <xsl:apply-templates/>
119 </a>
[24115]120 </xsl:otherwise>
121 </xsl:choose>
122 </xsl:template>
[19860]123
[24115]124 <xsl:template match="gsf:icon">
125 <xsl:choose>
126 <xsl:when test="@type='classifier'">
[24458]127 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
[24115]128 </xsl:when>
[26043]129 <xsl:when test="@type='web'">
130 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, 'webicon')]"/>
131 </xsl:when>
[25361]132 <xsl:when test="not(@type) or @type='document'">
[26100]133 <img style="border:0px"><xslt:attribute name="id">documentBasketBook<xslt:value-of select="/page/pageResponse/collection/@name"/>:<xslt:value-of select="@nodeID"/></xslt:attribute><xslt:attribute name="src">
134 <xslt:choose>
135 <xslt:when test="@docType='hierarchy' and @nodeType='root'">
136 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
137 </xslt:when>
138 <xslt:otherwise>
139 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/>
140 </xslt:otherwise>
141 </xslt:choose>
142 </xslt:attribute></img>
[24115]143 </xsl:when>
144 </xsl:choose>
145 </xsl:template>
[25941]146
[26023]147 <!-- calls a template in gslib.xsl in order to avoid xsl vs xslt issue -->
[26031]148 <!--<xsl:template match="gsf:equivlinkgs3">
[26023]149 <xslt:call-template name="equivDocLinks">
150 <xslt:with-param name="count" select="0"/>
151 </xslt:call-template>
[26031]152 </xsl:template>-->
[26023]153
154 <!-- Another way (also works with DSpace tutorial): build all the equivalent document links for the current document in one go. No looping necessary: handled in function call. -->
[26043]155 <xsl:template match="gsf:equivlinkgs3" name="gsf:equivlinkgs3">
[26023]156 <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
157 <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>
158 <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
159
160 <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" />
161 <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/>
[26031]162 </xsl:template>
[26023]163
164<!--
165In the collection's format statement, could have the following javascript+XSLT in place of
166the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and gslib.xsl).
167<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot;
168</xsl:text>
169<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/>
170<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot;
171</xsl:text>
172<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/>
173<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot;
174</xsl:text>
175<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/>
176<xsl:text disable-output-escaping="yes">&quot;];for (var i=0; i&lt;equivDocIcon.length; i++) { document.write(equivDocStartLink[i]+ equivDocIcon[i] + equivDocEndLink[i]); }&lt;/script&gt;
177</xsl:text>
178-->
179
[25941]180 <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:
181 <a><xsl:attribute name="href"><gsf:metadata name="httpPath" type="collection"/>/index/assoc/<gsf:metadata name="archivedir"/>/<gsf:metadata name="srclinkFile"/>#search=&amp;quot;<gsf:cgi-param name="query"/>&amp;quot;</xsl:attribute>src doc link with query highlighting</a> -->
182 <xsl:template match="gsf:cgi-param">
183 <xslt:value-of disable-output-escaping="yes" select="/page/pageRequest/paramList/param[@name='s1.{@name}']/@value"/>
184 </xsl:template>
[24359]185
[25752]186 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
187 a string defined in either collectionConfig.xml or else the interface dictionaries.
188 If the requested string occurs in neither, the request string itself will be output. -->
[25732]189 <xsl:template match="gsf:displayText">
[25752]190 <xslt:variable name="displaytext">
191 <xsl:call-template name="gsf:displayItem"/>
192 </xslt:variable>
193
194 <xslt:choose>
195 <xslt:when test="$displaytext != ''">
196 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
197 </xslt:when>
198 <xslt:otherwise>
199 <xslt:variable name="interfacetxt">
200 <xsl:call-template name="gsf:interfaceText"/>
201 </xslt:variable>
202
203 <xslt:choose>
204 <xslt:when test="$interfacetxt != ''">
205 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
206 </xslt:when>
207 <xslt:otherwise>
208 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
209 </xslt:otherwise>
210 </xslt:choose>
211 </xslt:otherwise>
212 </xslt:choose>
213 </xsl:template>
214
215 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
216 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
[25732]217 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItem[@name='{@name}']"/>
218 </xsl:template>
219
[25752]220 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
221 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
[25732]222 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
223 </xsl:template>
224
[24792]225 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
[26092]226 <xsl:template match="gsf:metadata">
227 <xsl:if test="not(@hidden = 'true')">
228 <!-- set hidden=true on a gsf:metadata so that it gets retrieved from the server but not displayed -->
229 <xsl:variable name="meta_name"><xsl:call-template name="getMetadataName"/></xsl:variable>
230 <xsl:variable name="separator"><xsl:choose><xsl:when test="@separator"><xsl:value-of disable-output-escaping='yes' select="@separator"/></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose></xsl:variable>
[26093]231 <xsl:variable name="postest">
232 <xsl:choose><xsl:when test="@pos = 'first'">position()=1</xsl:when><xsl:when test="@pos = 'last'">position() = last()</xsl:when><xsl:when test="@pos">position() = <xsl:value-of select="@pos"/></xsl:when><xsl:otherwise>true()</xsl:otherwise></xsl:choose>
233 </xsl:variable>
234 <xsl:variable name="multiple"><xsl:choose><xsl:when test="@pos">false()</xsl:when><xsl:otherwise>true()</xsl:otherwise></xsl:choose></xsl:variable>
[26092]235 <xslt:for-each><xsl:attribute name="select">
236 <xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>metadataList/metadata[@name='<xsl:value-of select="$meta_name"/>'<xsl:if test="@lang"><xsl:text> and @lang=</xsl:text><xsl:value-of select="@lang"/></xsl:if><xsl:text>]</xsl:text></xsl:attribute>
[26093]237 <xslt:if test="{$postest}">
238 <xslt:if test="{$multiple} and position()>1"><xsl:value-of select="$separator"/></xslt:if>
[26092]239 <xsl:choose>
240 <xsl:when test="@format">
241 <xslt:value-of disable-output-escaping='yes' select="util:{@format}(., /page/@lang )"/>
242 </xsl:when>
243 <xsl:otherwise>
244 <xslt:value-of disable-output-escaping='yes' select="."/>
245</xsl:otherwise>
246 </xsl:choose>
[26093]247 </xslt:if>
[26092]248 </xslt:for-each>
249 </xsl:if>
250 </xsl:template>
251
252 <xsl:template name="getMetadataName">
253 <xsl:if test='@select'>
254 <xsl:value-of select='@select'/>
255 <xsl:text>_</xsl:text>
256 </xsl:if>
257 <xsl:value-of select="@name"/>
258 </xsl:template>
259
[24115]260 <xsl:template match="gsf:text">
[26020]261 <xslt:call-template name="documentNodeText"/>
[24115]262 </xsl:template>
[19860]263
[24792]264 <xsl:template match="gsf:choose-metadata">
265 <xslt:choose>
266 <xsl:for-each select="gsf:metadata">
267 <xslt:when>
[26093]268 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
[24792]269 <xsl:apply-templates select="."/>
270 </xslt:when>
271 </xsl:for-each>
272 <xsl:if test="gsf:default">
273 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
274 </xsl:if>
275 </xslt:choose>
276 </xsl:template>
[19860]277
[24115]278 <xsl:template match="gsf:switch">
[26093]279 <xsl:variable name="meta-name"><xsl:for-each select="gsf:metadata"><xsl:call-template name="getMetadataName"/></xsl:for-each></xsl:variable>
[26092]280 <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'], /page/@lang )"/></xsl:when><xsl:otherwise><xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
[24115]281 <xslt:choose>
282 <xsl:for-each select="gsf:when">
283 <xslt:when test="util:{@test}($meta, '{@test-value}')">
284 <xsl:apply-templates/>
285 </xslt:when>
286 </xsl:for-each>
287 <xsl:if test="gsf:otherwise">
288 <xslt:otherwise>
289 <xsl:apply-templates select="gsf:otherwise/node()"/>
290 </xslt:otherwise>
291 </xsl:if>
292 </xslt:choose>
293 </xsl:template>
[19860]294
[24115]295 <xsl:template match="*">
296 <xsl:copy>
297 <xsl:copy-of select="@*"/>
298 <xsl:apply-templates/>
299 </xsl:copy>
300 </xsl:template>
[19860]301
302</xsl:stylesheet>
303
304
Note: See TracBrowser for help on using the repository browser.