1 | <?xml version="1.0"?> |
---|
2 | <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
3 | xmlns:my="myFunctions"> |
---|
4 | |
---|
5 | <!-- |
---|
6 | <purpose>generic functions and templates for displaying/summarizing table-data</purpose> |
---|
7 | <history> |
---|
8 | <change on="2010-03-19" type="created" by="vr">based on 3RMA/suki/dc4_commons.xsl</change> |
---|
9 | <change on="2010-03-23" type="changed" by="vr">really started rework - added html wrapper, ...</change> |
---|
10 | </history> |
---|
11 | |
---|
12 | --> |
---|
13 | <xsl:include href="params.xsl"/> |
---|
14 | |
---|
15 | <!-- <xsl:param name="mode" select="'html'" /> --> |
---|
16 | |
---|
17 | <xsl:param name="dict_file" select="'dict.xml'" /> |
---|
18 | <xsl:variable name="dict" select="document($dict_file)" /> |
---|
19 | |
---|
20 | <!-- params for include-processing |
---|
21 | moved to params.xsl |
---|
22 | <xsl:param name="components_uri" select="'http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/'" /> |
---|
23 | <xsl:param name="prefix_replace" select="'file:///C:/Users/master/3lingua/clarin/CMDI/_repo2/metadata/toolkit/components'" /> |
---|
24 | --> |
---|
25 | |
---|
26 | <xsl:param name="src_file" /> |
---|
27 | <!-- FIXME: he? --> |
---|
28 | <xsl:param name="root_uri" select="$src_file" /> |
---|
29 | |
---|
30 | <xsl:variable name="terms_setup" select="document($terms_setup_uri)" /> |
---|
31 | |
---|
32 | <xsl:template match="/"> |
---|
33 | <xsl:message>root_document-uri:<xsl:value-of select="$root_uri" /></xsl:message> |
---|
34 | <xsl:message>components_uri:<xsl:value-of select="$components_uri" /></xsl:message> |
---|
35 | <xsl:choose> |
---|
36 | <xsl:when test="contains($format,'htmlpage')" > |
---|
37 | <xsl:call-template name="html"/> |
---|
38 | </xsl:when> |
---|
39 | <xsl:otherwise> |
---|
40 | <xsl:call-template name="continue-root"/> |
---|
41 | </xsl:otherwise> |
---|
42 | </xsl:choose> |
---|
43 | </xsl:template> |
---|
44 | |
---|
45 | |
---|
46 | <xsl:template name="html"> |
---|
47 | |
---|
48 | <html> |
---|
49 | <head> |
---|
50 | <title><xsl:value-of select="$title"/></title> |
---|
51 | |
---|
52 | <link rel="stylesheet" href="{$base_dir}/style/jquery/clarindotblue/jquery-ui-1.8.5.custom.css" type="text/css" /> |
---|
53 | <link href="{$base_dir}/style/jquery/jquery-treeview/jquery.treeview.css" rel="stylesheet" /> |
---|
54 | <link href="{$base_dir}/style/jquery/treetable/jquery.treeTable.css" rel="stylesheet" ></link> |
---|
55 | <link href="{$base_dir}/style/cmds-ui.css" type="text/css" rel="stylesheet"></link> |
---|
56 | |
---|
57 | <link href="{$base_dir}style/jquery/jquery-textboxlist/TextboxList.css" rel="stylesheet" type="text/css"></link> |
---|
58 | <link href="{$base_dir}style/jquery/jquery-autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css"></link> |
---|
59 | |
---|
60 | <script src="{$base_dir}/scripts/jquery/js/jquery-1.4.2.js" type="text/javascript"></script> |
---|
61 | <script src="{$base_dir}/scripts/jquery/js/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script> |
---|
62 | <script src="{$base_dir}/scripts/jquery/jquery-treeview/jquery.treeview.js" type="text/javascript"></script> |
---|
63 | <script src="{$base_dir}/scripts/jquery/jquery-treeTable/jquery.treeTable.js" type="text/javascript"></script> |
---|
64 | <!-- <script src="scripts/jquery/jquery-autocomplete/jquery.autocomplete.js" type="text/javascript"></script> |
---|
65 | |
---|
66 | <script src="scripts/mdservice_searchclause.js" type="text/javascript"></script> |
---|
67 | <script src="scripts/mdservice_model.js" type="text/javascript"></script> |
---|
68 | <script src="scripts/mdservice2_ui.js" type="text/javascript"></script> |
---|
69 | --> |
---|
70 | |
---|
71 | <xsl:call-template name="callback-header"/> |
---|
72 | </head> |
---|
73 | <body> |
---|
74 | <h1><xsl:value-of select="$title"/></h1> |
---|
75 | <xsl:call-template name="continue-root"/> |
---|
76 | </body> |
---|
77 | </html> |
---|
78 | </xsl:template> |
---|
79 | |
---|
80 | <xsl:template name="callback-header"> |
---|
81 | |
---|
82 | </xsl:template> |
---|
83 | |
---|
84 | <!-- |
---|
85 | <xsl:template name="continue-root"> |
---|
86 | |
---|
87 | </xsl:template> |
---|
88 | --> |
---|
89 | <!-- Start includes --> |
---|
90 | |
---|
91 | <!-- resolve includes --> |
---|
92 | <xsl:template match="@*|node()" mode="include"> |
---|
93 | <xsl:copy> |
---|
94 | <xsl:apply-templates select="@*|node()" mode="include"/> |
---|
95 | </xsl:copy> |
---|
96 | </xsl:template> |
---|
97 | |
---|
98 | |
---|
99 | <xsl:template match="CMD_Component[@ComponentId]" mode="include"> |
---|
100 | |
---|
101 | <!-- <xsl:param name="resolved_path" select="if (matches(@filename, $prefix)) then $prefix_replace else './'" /> --> |
---|
102 | |
---|
103 | <!-- <xsl:variable name="resolved_fn" select="if (matches(@filename, $prefix)) then replace(@filename, $prefix, $prefix_replace) else if (document-uri(/)) then @filename else concat( $root_uri, '/', @filename)" /> --> |
---|
104 | <!-- <xsl:variable name="resolved_fn" select="concat($components_uri, @ComponentId)" /> --> |
---|
105 | <xsl:variable name="resolved_fn" select="concat($components_uri, my:extractID(@ComponentId))" /> |
---|
106 | <xsl:variable name="compid" select="@ComponentId" /> |
---|
107 | |
---|
108 | <!-- <xsl:variable name="resolved_fn" select="replace(@filename, 'http://www.clarin.eu/cmd/components', 'file:///C:/Users/master/3lingua/clarin/CMDI/_repo2/metadata/toolkit/components')" /> --> |
---|
109 | |
---|
110 | <xsl:message>resolved_fn:<xsl:value-of select="$resolved_fn" /></xsl:message> |
---|
111 | <xsl:message>document-uri:<xsl:value-of select="document-uri(/)" /></xsl:message> |
---|
112 | <!-- some of the outer CMD_Component attributes can overwrite the inner CMD_Component attributes --> |
---|
113 | |
---|
114 | <xsl:variable name="outer-attr" select="@CardinalityMin|@CardinalityMax"/> |
---|
115 | <xsl:for-each select="document($resolved_fn)/CMD_ComponentSpec/CMD_Component"> |
---|
116 | <xsl:variable name="inner-attr" select="@*"/> |
---|
117 | <xsl:copy> |
---|
118 | <!-- <xsl:attribute name="filename" select="replace($resolved_fn,$prefix_replace,'')" /> --> |
---|
119 | |
---|
120 | <xsl:attribute name="ComponentId" select="$compid" /> |
---|
121 | <xsl:apply-templates select="$outer-attr" mode="include"/> |
---|
122 | <xsl:apply-templates select="$inner-attr[not(node-name(.) = $outer-attr/node-name(.))]" mode="include"/> |
---|
123 | <xsl:apply-templates select="node()" mode="include"> |
---|
124 | <!-- <xsl:with-param name="resolved_path" select="$resolved_path" /> --> |
---|
125 | </xsl:apply-templates> |
---|
126 | </xsl:copy> |
---|
127 | </xsl:for-each> |
---|
128 | </xsl:template> |
---|
129 | |
---|
130 | |
---|
131 | <xsl:template match="componentDescription[id] | profileDescription[id]" mode="include"> |
---|
132 | |
---|
133 | <!-- <xsl:variable name="resolved_uri" select="concat($root_uri, '/', id)" />--> |
---|
134 | <xsl:variable name="resolved_uri" select="concat($cmdprofiles_uri , '/', my:extractID(id))" /> |
---|
135 | |
---|
136 | |
---|
137 | <xsl:message>resolved_uri:<xsl:value-of select="$resolved_uri" /></xsl:message> |
---|
138 | <xsl:message>document-uri:<xsl:value-of select="document-uri(/)" /></xsl:message> |
---|
139 | |
---|
140 | <xsl:copy> |
---|
141 | <xsl:apply-templates mode="include" /> |
---|
142 | <xsl:apply-templates select="document($resolved_uri)" mode="include" /> |
---|
143 | <!-- <xsl:copy-of select="document($resolved_uri)" /> --> |
---|
144 | <!-- <xsl:copy-of select="document(id, $root_uri)" /> --> |
---|
145 | </xsl:copy> |
---|
146 | </xsl:template> |
---|
147 | |
---|
148 | <!-- Stop includes --> |
---|
149 | |
---|
150 | <!-- generic templates --> |
---|
151 | <xsl:template name="attr-detail-div" > |
---|
152 | <div class="detail"> |
---|
153 | <xsl:for-each select="@*" > |
---|
154 | <div class="cmds-elem-prop"><span class="label"><xsl:value-of select="name()" />: </span> |
---|
155 | <span class="value"><xsl:value-of select="." /></span></div> |
---|
156 | </xsl:for-each> |
---|
157 | </div> |
---|
158 | </xsl:template> |
---|
159 | |
---|
160 | <!-- should be obsoleted by model2matrix.xsl |
---|
161 | but it is not.. |
---|
162 | --> |
---|
163 | <xsl:variable name="term_matrix" > |
---|
164 | |
---|
165 | <xsl:for-each select="//CMD_Element" > |
---|
166 | <xsl:variable name="context" select="my:context(.)" > |
---|
167 | </xsl:variable> |
---|
168 | <Term elem="{@name}" datcat="{@ConceptLink}" profile="{ancestor::profileDescription[1]/name}" |
---|
169 | parent="{ancestor::CMD_Component[1]/@name}" context="{$context}" > |
---|
170 | <xsl:copy-of select="." /> |
---|
171 | </Term> |
---|
172 | </xsl:for-each> |
---|
173 | |
---|
174 | </xsl:variable> |
---|
175 | <!-- |
---|
176 | <xsl:template match="Term" mode="matrix" > |
---|
177 | |
---|
178 | <xsl:for-each select=".//Term" > |
---|
179 | <xsl:variable name="context" select="my:context(.)" > |
---|
180 | </xsl:variable> |
---|
181 | <Term elem="{@name}" datcat="{my:term2datcat(@name)}" profile="{ancestor::profileDescription[1]/name}" |
---|
182 | parent="{ancestor::Term[1]/@name}" context="{$context}" > |
---|
183 | <xsl:copy-of select="." /> |
---|
184 | </Term> |
---|
185 | </xsl:for-each> |
---|
186 | |
---|
187 | </xsl:template> |
---|
188 | |
---|
189 | --> |
---|
190 | |
---|
191 | <xsl:function name="my:profilematrix" > |
---|
192 | <xsl:param name="term"/> |
---|
193 | |
---|
194 | <xsl:variable name="profile" select="my:profile($term,true())" /> |
---|
195 | <Terms name="{$profile/name}" id="{$profile/id}"> |
---|
196 | <xsl:for-each select="$profile//CMD_Component|$profile//CMD_Element" > |
---|
197 | <xsl:variable name="context" select="my:context(.)" /> |
---|
198 | |
---|
199 | <xsl:variable name="id" > |
---|
200 | <xsl:choose> |
---|
201 | <xsl:when test="@ComponentId"> |
---|
202 | <xsl:value-of select="@ComponentId" /> |
---|
203 | </xsl:when> |
---|
204 | <xsl:otherwise> |
---|
205 | <xsl:value-of select="ancestor::CMD_Component[@ComponentId][1]/@ComponentId" /><xsl:text>#</xsl:text> |
---|
206 | <xsl:for-each select="ancestor::CMD_Component[not(descendant-or-self::CMD_Component[@ComponentId])]" > |
---|
207 | <xsl:value-of select="@name" />.</xsl:for-each><xsl:value-of select="@name" /> |
---|
208 | </xsl:otherwise> |
---|
209 | </xsl:choose> |
---|
210 | </xsl:variable> |
---|
211 | <Term name="{@name}" datcat="{@ConceptLink}" id="{$id}" |
---|
212 | parent="{ancestor::CMD_Component[1]/@name}" context="{$context}" |
---|
213 | > |
---|
214 | <!-- <xsl:copy-of select="." /> --> |
---|
215 | </Term> |
---|
216 | </xsl:for-each> |
---|
217 | </Terms> |
---|
218 | |
---|
219 | </xsl:function> |
---|
220 | |
---|
221 | <xsl:function name="my:profile" > |
---|
222 | <xsl:param name="term"/> |
---|
223 | <xsl:param name="resolve" /> <!-- true|false--> |
---|
224 | |
---|
225 | <xsl:message>cmdprofiles_uri: <xsl:value-of select="$cmdprofiles_uri" /></xsl:message> |
---|
226 | |
---|
227 | <xsl:variable name="profile" select="doc($cmdprofiles_uri)//profileDescription[name=$term]" /> |
---|
228 | |
---|
229 | <xsl:choose> |
---|
230 | <xsl:when test="$resolve=true()"> |
---|
231 | <xsl:apply-templates select="$profile" mode="include" /> |
---|
232 | </xsl:when> |
---|
233 | <xsl:otherwise> |
---|
234 | <xsl:copy-of select="$profile" /> |
---|
235 | </xsl:otherwise> |
---|
236 | </xsl:choose> |
---|
237 | |
---|
238 | |
---|
239 | </xsl:function> |
---|
240 | |
---|
241 | <!-- |
---|
242 | <xsl:function name="my:term2datcat"> |
---|
243 | <xsl:param name="term"/> |
---|
244 | <xsl:value-of select="$term_matrix/*[@elem=$term]/@datcat" /> |
---|
245 | </xsl:function> |
---|
246 | --> |
---|
247 | |
---|
248 | <xsl:function name="my:dict"> |
---|
249 | <xsl:param name="key"/> |
---|
250 | <xsl:value-of select="my:dict($key, $key)" /> |
---|
251 | </xsl:function> |
---|
252 | |
---|
253 | <xsl:function name="my:dict"> |
---|
254 | <xsl:param name="key"/> |
---|
255 | <xsl:param name="fallback"/> |
---|
256 | <xsl:choose> |
---|
257 | <xsl:when test="$dict/list/item[@key=$key]" > |
---|
258 | <xsl:value-of select="$dict/list/item[@key=$key]" /> |
---|
259 | </xsl:when> |
---|
260 | <xsl:when test="$dict/list/item[.=$key]" > |
---|
261 | <xsl:value-of select="$dict/list/item[.=$key]/@key" /> |
---|
262 | </xsl:when> |
---|
263 | <xsl:otherwise> |
---|
264 | <xsl:value-of select="$fallback" /> |
---|
265 | </xsl:otherwise> |
---|
266 | </xsl:choose> |
---|
267 | </xsl:function> |
---|
268 | |
---|
269 | <xsl:function name="my:extractID" > |
---|
270 | <xsl:param name="uri" /> |
---|
271 | |
---|
272 | <xsl:choose> |
---|
273 | <xsl:when test="contains($uri,$isocat_base_uri)"> |
---|
274 | <xsl:value-of select="substring-after($uri, $isocat_base_uri)" /> |
---|
275 | </xsl:when> |
---|
276 | <xsl:when test="contains($uri,$components_id_prefix)"> |
---|
277 | <!-- <xsl:value-of select="substring-after($uri,$components_id_prefix)" /> --> |
---|
278 | <xsl:value-of select="substring-after($uri, $components_id_prefix)" /> |
---|
279 | </xsl:when> |
---|
280 | <xsl:otherwise><xsl:value-of select="$uri" /></xsl:otherwise> |
---|
281 | </xsl:choose> |
---|
282 | </xsl:function> |
---|
283 | |
---|
284 | |
---|
285 | <xsl:function name="my:shortURL" > |
---|
286 | <xsl:param name="url" /> |
---|
287 | <!-- <xsl:value-of select="replace($url, 'http://www.isocat.org/datcat/','isocat:')" /> --> |
---|
288 | <xsl:variable name="matching_termset" select="$terms_setup/Termsets/Termset[starts-with($url,@url_prefix)]" /> |
---|
289 | |
---|
290 | <xsl:value-of select="if (exists($matching_termset)) then replace($url, $matching_termset/@url_prefix, concat($matching_termset/@id,':')) else $url" /> |
---|
291 | </xsl:function> |
---|
292 | |
---|
293 | <!-- rewrite specific URLs (linking to target services) to redirect them locally (via MDService) |
---|
294 | should work for: dcif:dataCategory@pid, pcompone |
---|
295 | --> |
---|
296 | <xsl:function name="my:rewriteURL" > |
---|
297 | <xsl:param name="url" /> |
---|
298 | <xsl:choose> |
---|
299 | <xsl:when test="contains($url,$isocat_base_uri)"> |
---|
300 | <xsl:value-of select="replace($url, $isocat_uri_match, $isocat_uri_replace)" /> |
---|
301 | </xsl:when> |
---|
302 | <xsl:otherwise><xsl:value-of select="concat($detail_complist_prefix, my:extractID($url))" /></xsl:otherwise> |
---|
303 | </xsl:choose> |
---|
304 | </xsl:function> |
---|
305 | |
---|
306 | <!-- previously known as comppath --> |
---|
307 | <xsl:function name="my:context" > |
---|
308 | <xsl:param name="child" /> |
---|
309 | <xsl:variable name="collect" > |
---|
310 | <xsl:for-each select="$child/ancestor::CMD_Component|$child/ancestor::Term" > |
---|
311 | <xsl:value-of select="@name" />.</xsl:for-each><xsl:value-of select="$child/@name" /> |
---|
312 | </xsl:variable> |
---|
313 | <xsl:value-of select="$collect" /> |
---|
314 | </xsl:function> |
---|
315 | |
---|
316 | <!-- |
---|
317 | <xsl:function name="my:numberFormat"> |
---|
318 | <xsl:param name="unit" /> |
---|
319 | <xsl:choose> |
---|
320 | <xsl:when test="$unit='count' or $unit='count-distinct'" ><xsl:value-of select="$format_count" /></xsl:when> |
---|
321 | <xsl:when test="$unit='kg'" ><xsl:value-of select="$format_kg" /></xsl:when> |
---|
322 | <xsl:when test="$unit='t'" ><xsl:value-of select="$format_t" /></xsl:when> |
---|
323 | <xsl:when test="$unit='m3'" ><xsl:value-of select="$format_m3" /></xsl:when> |
---|
324 | <xsl:when test="$unit='per' or $unit='percent'" ><xsl:value-of select="$format_per" /></xsl:when> |
---|
325 | <xsl:when test="$unit='sum'" ><xsl:value-of select="$format_kg" /></xsl:when> |
---|
326 | <xsl:otherwise><xsl:value-of select="$format_default" /></xsl:otherwise> |
---|
327 | </xsl:choose> |
---|
328 | </xsl:function> |
---|
329 | --> |
---|
330 | |
---|
331 | </xsl:stylesheet> |
---|