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

Last change on this file since 24458 was 24458, checked in by sjm84, 13 years ago

Created the gs variable in Javascript as well as gsf:variable that creates a variable in both XSLT and Javascript. Also, can now be accessed in config_format.xsl

File size: 8.7 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: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">
9 <xsl:param name="interface_name"/>
10 <xsl:param name="library_name"/>
11
12 <xsl:output method="xml"/>
13 <xsl:namespace-alias stylesheet-prefix="xslt" result-prefix="xsl"/>
14
15 <xsl:template match="format">
16 <format>
17 <xsl:apply-templates/>
18 </format>
19 </xsl:template>
20
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>
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>
42
43 <xsl:template match="gsf:link">
44 <xsl:choose>
45 <xsl:when test="@type='classifier'">
46 <a>
47 <xslt:attribute name='href'>
48 <xslt:value-of select='$library_name'/>
49 <xsl:text>?a=b&amp;rt=r&amp;s=</xsl:text>
50 <xslt:value-of select='/page/pageResponse/service/@name'/>
51 <xsl:text>&amp;c=</xsl:text>
52 <xslt:value-of select='/page/pageResponse/collection/@name'/>
53 <xsl:text>&amp;cl=</xsl:text>
54 <xslt:value-of select='@nodeID'/>
55 <xslt:if test="classifierNode|documentNode">
56 <xsl:text>.pr</xsl:text>
57 </xslt:if>
58 <xslt:if test="parent::node()[@orientation='horizontal']">
59 <xsl:text>&amp;sib=1</xsl:text>
60 </xslt:if>
61 </xslt:attribute>
62 <xsl:apply-templates/>
63 </a>
64 </xsl:when>
65 <xsl:when test="@type='source'">
66 <a><xslt:attribute name='href'><xslt:value-of
67 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
68 disable-output-escaping="yes" select="metadataList/metadata[@name='assocfilepath']" />/<xslt:value-of
69 disable-output-escaping="yes" select="metadataList/metadata[@name='srclinkFile']" /></xslt:attribute>
70 <xsl:apply-templates/>
71 </a>
72 </xsl:when>
73
74 <xsl:otherwise> <!-- a document link -->
75 <xslt:variable name="bookswitch">
76 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
77 </xslt:variable>
78 <xslt:choose>
79 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
80 <a>
81 <xslt:attribute name="href">
82 <xslt:value-of select='$library_name'/>
83 <xsl:text>?a=d&amp;ed=1&amp;book=on&amp;c=</xsl:text>
84 <xslt:value-of select='/page/pageResponse/collection/@name'/>
85 <xsl:text>&amp;d=</xsl:text>
86 <xslt:value-of select='@nodeID'/>
87 <xsl:text>&amp;dt=</xsl:text>
88 <xslt:value-of select='@docType'/>
89 <xslt:if test="@nodeType='leaf'">
90 <xsl:text>&amp;sib=1</xsl:text>
91 </xslt:if>
92 <xsl:text>&amp;p.a=</xsl:text>
93 <xslt:value-of select="/page/pageRequest/@action"/>
94 <xsl:text>&amp;p.sa=</xsl:text>
95 <xsl:value-of select="/page/pageRequest/@subaction"/>
96 <xsl:text>&amp;p.s=</xsl:text>
97 <xslt:value-of select="/page/pageResponse/service/@name"/>
98 </xslt:attribute>
99 <xsl:apply-templates/>
100 </a>
101 </xslt:when>
102 <xslt:otherwise>
103 <a>
104 <xslt:attribute name="href">
105 <xslt:value-of select='$library_name'/>
106 <xsl:text>?a=d&amp;ed=1&amp;book=off&amp;c=</xsl:text>
107 <xslt:value-of select='/page/pageResponse/collection/@name'/>
108 <xsl:text>&amp;d=</xsl:text>
109 <xslt:value-of select='@nodeID'/>
110 <xsl:text>&amp;dt=</xsl:text>
111 <xslt:value-of select='@docType'/>
112 <xslt:if test="@nodeType='leaf'">
113 <xsl:text>&amp;sib=1</xsl:text>
114 </xslt:if>
115 <xsl:text>&amp;p.a=</xsl:text>
116 <xslt:value-of select="/page/pageRequest/@action"/>
117 <xsl:text>&amp;p.sa=</xsl:text>
118 <xsl:value-of select="/page/pageRequest/@subaction"/>
119 <xsl:text>&amp;p.s=</xsl:text>
120 <xslt:value-of select="/page/pageResponse/service/@name"/>
121 </xslt:attribute>
122 <xsl:apply-templates/>
123 </a>
124 </xslt:otherwise>
125 </xslt:choose>
126 </xsl:otherwise>
127 </xsl:choose>
128 </xsl:template>
129
130 <xsl:template match="gsf:icon">
131 <xsl:choose>
132 <xsl:when test="@type='classifier'">
133 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
134 </xsl:when>
135 <xsl:when test="@type='document'">
136 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/></xsl:attribute></img>
137 </xsl:when>
138 </xsl:choose>
139 </xsl:template>
140
141 <xsl:template match="gsf:metadata[@format]">
142 <xslt:value-of disable-output-escaping="yes">
143 <xsl:attribute name="select">
144 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
145 <xsl:value-of select="@format"/>
146 <xsl:text>(metadataList/metadata[@name='</xsl:text>
147 <xsl:apply-templates select="." mode="get-metadata-name"/>
148 <xsl:text>'], /page/@lang )</xsl:text>
149 </xsl:attribute>
150 </xslt:value-of>
151 </xsl:template>
152
153 <xsl:template match="gsf:metadata">
154 <xslt:value-of disable-output-escaping="yes">
155 <xsl:attribute name="select">
156 <xsl:text>metadataList/metadata[@name='</xsl:text>
157 <xsl:apply-templates select="." mode="get-metadata-name"/>
158 <xsl:text>']</xsl:text>
159 </xsl:attribute>
160 </xslt:value-of>
161 </xsl:template>
162
163 <xsl:template match="gsf:metadata" mode="get-metadata-name">
164 <xsl:if test="@multiple='true'">
165 <xsl:text>all_</xsl:text>
166 </xsl:if>
167 <xsl:if test='@select'>
168 <xsl:value-of select='@select'/>
169 <xsl:text>_</xsl:text>
170 </xsl:if>
171 <xsl:if test="@separator">
172 <xsl:text>*</xsl:text>
173 <xsl:value-of select='@separator'/>
174 <xsl:text>*_</xsl:text>
175 </xsl:if>
176 <xsl:value-of select="@name"/>
177 </xsl:template>
178
179 <xsl:template match="gsf:metadata-old">
180 <xslt:value-of disable-output-escaping="yes">
181 <xsl:attribute name="select">
182 <xsl:text>metadataList/metadata[@name="</xsl:text>
183 <xsl:choose>
184 <xsl:when test="@select='parent'">
185 <xsl:text>parent_</xsl:text>
186 </xsl:when>
187 <xsl:when test="@select='root'">
188 <xsl:text>root_</xsl:text>
189 </xsl:when>
190 <xsl:when test="@select='ancestors'">
191 <xsl:text>ancestors'</xsl:text>
192 <xsl:value-of select='@separator'/>
193 <xsl:text>'_</xsl:text>
194 </xsl:when>
195 <xsl:when test="@select='siblings'">
196 <xsl:text>siblings_'</xsl:text>
197 <xsl:value-of select='@separator'/>
198 <xsl:text>'_</xsl:text>
199 </xsl:when>
200 </xsl:choose>
201 <xsl:value-of select="@name"/>
202 <xsl:text>"]</xsl:text>
203 </xsl:attribute>
204 </xslt:value-of>
205 </xsl:template>
206
207 <xsl:template match="gsf:text">
208 <xslt:apply-templates select="nodeContent"/>
209 </xsl:template>
210
211 <xsl:template match="gsf:choose-metadata">
212 <xslt:choose>
213 <xsl:for-each select="gsf:metadata">
214 <xslt:when>
215 <xsl:attribute name="test">metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
216 <xsl:apply-templates select="."/>
217 </xslt:when>
218 </xsl:for-each>
219 <xsl:if test="gsf:default">
220 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
221 </xsl:if>
222 </xslt:choose>
223 </xsl:template>
224
225 <xsl:template match="gsf:switch">
226 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
227 <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}(metadataList/metadata[@name='{$meta-name}'])"/></xsl:when><xsl:otherwise><xslt:value-of select="metadataList/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
228 <xslt:choose>
229 <xsl:for-each select="gsf:when">
230 <xslt:when test="util:{@test}($meta, '{@test-value}')">
231 <xsl:apply-templates/>
232 </xslt:when>
233 </xsl:for-each>
234 <xsl:if test="gsf:otherwise">
235 <xslt:otherwise>
236 <xsl:apply-templates select="gsf:otherwise/node()"/>
237 </xslt:otherwise>
238 </xsl:if>
239 </xslt:choose>
240 </xsl:template>
241
242 <xsl:template match="*">
243 <xsl:copy>
244 <xsl:copy-of select="@*"/>
245 <xsl:apply-templates/>
246 </xsl:copy>
247 </xsl:template>
248
249</xsl:stylesheet>
250
251
Note: See TracBrowser for help on using the repository browser.