source: main/trunk/greenstone3/web/interfaces/oran/transform/config_format.xsl@ 25361

Last change on this file since 25361 was 25361, checked in by sjm84, 12 years ago

Replacing some URLs with the RESTful versions

File size: 8.6 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">
48 <img>
49 <xslt:attribute name='src'>
50 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
51 <xsl:text>/index/assoc/</xsl:text>
[25145]52 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name = 'assocfilepath']"/>
[25002]53 <xsl:text>/</xsl:text>
54 <xsl:choose>
55 <xsl:when test="@type = 'thumb'">
[25177]56 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Thumb']"/>
[25002]57 </xsl:when>
58 <xsl:when test="@type = 'screen'">
[25177]59 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Screen']"/>
[25002]60 </xsl:when>
61 <xsl:when test="@type = 'source'">
[25177]62 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'SourceFile']"/>
[25002]63 </xsl:when>
64 </xsl:choose>
65 </xslt:attribute>
66 </img>
67 </xsl:template>
68
[24115]69 <xsl:template match="gsf:link">
70 <xsl:choose>
71 <xsl:when test="@type='classifier'">
72 <a>
73 <xslt:attribute name='href'>
74 <xslt:value-of select='$library_name'/>
[25361]75
76 <!--
[24115]77 <xsl:text>?a=b&amp;rt=r&amp;s=</xsl:text>
78 <xslt:value-of select='/page/pageResponse/service/@name'/>
79 <xsl:text>&amp;c=</xsl:text>
80 <xslt:value-of select='/page/pageResponse/collection/@name'/>
81 <xsl:text>&amp;cl=</xsl:text>
82 <xslt:value-of select='@nodeID'/>
83 <xslt:if test="classifierNode|documentNode">
84 <xsl:text>.pr</xsl:text>
85 </xslt:if>
86 <xslt:if test="parent::node()[@orientation='horizontal']">
87 <xsl:text>&amp;sib=1</xsl:text>
88 </xslt:if>
[25361]89 -->
[24115]90 </xslt:attribute>
91 <xsl:apply-templates/>
92 </a>
93 </xsl:when>
[24127]94 <xsl:when test="@type='source'">
95 <a><xslt:attribute name='href'><xslt:value-of
96 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
[25177]97 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='assocfilepath']" />/<xslt:value-of
98 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='srclinkFile']" /></xslt:attribute>
[24127]99 <xsl:apply-templates/>
100 </a>
101 </xsl:when>
102
[24115]103 <xsl:otherwise> <!-- a document link -->
104 <xslt:variable name="bookswitch">
105 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
106 </xslt:variable>
[25361]107 <a>
108 <xslt:attribute name="href">
109 <xslt:value-of select='$library_name'/>
110 <xsl:text>/collection/</xsl:text>
111 <xslt:value-of select='/page/pageResponse/collection/@name'/>
112 <xsl:text>/document/</xsl:text>
113 <xslt:value-of select='@nodeID'/>
114 <xslt:if test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
115 <xsl:text>?book=on</xsl:text>
116 </xslt:if>
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>
[25361]129 <xsl:when test="not(@type) or @type='document'">
[24510]130 <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"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/></xslt:attribute></img>
[24115]131 </xsl:when>
132 </xsl:choose>
133 </xsl:template>
[24359]134
[24792]135 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
[25145]136 <xsl:template match="gsf:metadata">
[25002]137 <xslt:if test="not(@hidden = 'true')">
138 <xslt:value-of disable-output-escaping="yes">
139 <xsl:attribute name="select">
[25145]140 <xsl:if test="@format">
141 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
142 <xsl:value-of select="@format"/>
143 <xsl:text>(</xsl:text>
144 </xsl:if>
[25177]145 <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
[25002]146 <xsl:apply-templates select="." mode="get-metadata-name"/>
147 <xsl:text>']</xsl:text>
[25145]148 <xsl:if test="@format">
149 <xsl:text>, /page/@lang )</xsl:text>
150 </xsl:if>
[25002]151 </xsl:attribute>
152 </xslt:value-of>
153 </xslt:if>
[24792]154 </xsl:template>
[19860]155
[24115]156 <xsl:template match="gsf:metadata" mode="get-metadata-name">
157 <xsl:if test="@multiple='true'">
158 <xsl:text>all_</xsl:text>
159 </xsl:if>
160 <xsl:if test='@select'>
161 <xsl:value-of select='@select'/>
162 <xsl:text>_</xsl:text>
163 </xsl:if>
164 <xsl:if test="@separator">
165 <xsl:text>*</xsl:text>
166 <xsl:value-of select='@separator'/>
167 <xsl:text>*_</xsl:text>
168 </xsl:if>
169 <xsl:value-of select="@name"/>
170 </xsl:template>
[19860]171
[24115]172 <xsl:template match="gsf:metadata-old">
173 <xslt:value-of disable-output-escaping="yes">
174 <xsl:attribute name="select">
[25177]175 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
[24115]176 <xsl:choose>
177 <xsl:when test="@select='parent'">
178 <xsl:text>parent_</xsl:text>
179 </xsl:when>
180 <xsl:when test="@select='root'">
181 <xsl:text>root_</xsl:text>
182 </xsl:when>
183 <xsl:when test="@select='ancestors'">
184 <xsl:text>ancestors'</xsl:text>
185 <xsl:value-of select='@separator'/>
186 <xsl:text>'_</xsl:text>
187 </xsl:when>
188 <xsl:when test="@select='siblings'">
189 <xsl:text>siblings_'</xsl:text>
190 <xsl:value-of select='@separator'/>
191 <xsl:text>'_</xsl:text>
192 </xsl:when>
193 </xsl:choose>
194 <xsl:value-of select="@name"/>
195 <xsl:text>"]</xsl:text>
196 </xsl:attribute>
197 </xslt:value-of>
198 </xsl:template>
[19860]199
[24115]200 <xsl:template match="gsf:text">
201 <xslt:apply-templates select="nodeContent"/>
202 </xsl:template>
[19860]203
[24792]204 <xsl:template match="gsf:choose-metadata">
205 <xslt:choose>
206 <xsl:for-each select="gsf:metadata">
207 <xslt:when>
[25177]208 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
[24792]209 <xsl:apply-templates select="."/>
210 </xslt:when>
211 </xsl:for-each>
212 <xsl:if test="gsf:default">
213 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
214 </xsl:if>
215 </xslt:choose>
216 </xsl:template>
[19860]217
[24115]218 <xsl:template match="gsf:switch">
219 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
[25177]220 <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'])"/></xsl:when><xsl:otherwise><xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
[24115]221 <xslt:choose>
222 <xsl:for-each select="gsf:when">
223 <xslt:when test="util:{@test}($meta, '{@test-value}')">
224 <xsl:apply-templates/>
225 </xslt:when>
226 </xsl:for-each>
227 <xsl:if test="gsf:otherwise">
228 <xslt:otherwise>
229 <xsl:apply-templates select="gsf:otherwise/node()"/>
230 </xslt:otherwise>
231 </xsl:if>
232 </xslt:choose>
233 </xsl:template>
[19860]234
[24115]235 <xsl:template match="*">
236 <xsl:copy>
237 <xsl:copy-of select="@*"/>
238 <xsl:apply-templates/>
239 </xsl:copy>
240 </xsl:template>
[19860]241
242</xsl:stylesheet>
243
244
Note: See TracBrowser for help on using the repository browser.