source: cats/ISOcat/trunk/mod-ISOcat-interface-rest/representations/dcs2/html.xsl @ 5878

Last change on this file since 5878 was 5878, checked in by Menzo Windhouwer, 10 years ago

M mod-ISOcat-manage-system/manage/dump.acc

  • added dump of the info files
  • UTF-8 instead of utf-8

M mod-ISOcat-interface-rest/representations/dcs2/html.xsl

  • fixed link
File size: 20.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xs xd" xmlns:dcif="http://www.isocat.org/ns/dcif" xmlns:dcr="http://www.isocat.org/ns/dcr" xmlns:isocat="http://www.isocat.org/" version="2.0">
3
4    <xd:doc scope="stylesheet">
5        <xd:desc>
6            <xd:p><xd:b>Created on:</xd:b> May 11, 2011</xd:p>
7            <xd:p><xd:b>Author:</xd:b> menwin</xd:p>
8            <xd:p/>
9        </xd:desc>
10    </xd:doc>
11
12    <xsl:output method="xml" encoding="UTF-8"/>
13
14    <xsl:param name="title" select="'default'"/>
15    <xsl:param name="props">
16        <nvp/>
17    </xsl:param>
18
19    <xsl:param name="purpose" select="'default'"/>
20   
21    <xsl:param name="view-working-languages" select="''"/>
22
23    <xsl:key name="dc" match="dcif:dataCategory" use="@isocat:id"/>
24    <xsl:key name="isa" match="dcif:isA" use="@isocat:id"/>
25    <xsl:key name="value" match="dcif:value" use="@isocat:id"/>
26
27    <xsl:template match="text()" mode="#all"/>
28
29    <xsl:template match="/dcif:dataCategorySelection">
30        <html>
31            <head>
32                <title>
33                    <xsl:value-of select="@name"/>
34                </title>
35            </head>
36            <body>
37                <xsl:if test="$purpose='print'">
38                    <xsl:attribute name="onload" select="'self.print()'"/>
39                </xsl:if>
40                <h1 align="left">
41                    <xsl:value-of select="@name"/>
42                </h1>
43                <hr/>
44                <a href="#index">index</a>
45                <xsl:choose>
46                    <xsl:when test="exists(*/@isocat:rank)">
47                        <xsl:apply-templates>
48                            <xsl:sort select="@isocat:rank" data-type="number" order="descending"/>
49                        </xsl:apply-templates>
50                    </xsl:when>
51                    <xsl:otherwise>
52                        <xsl:apply-templates>
53                            <xsl:sort select="@isocat:name"/>
54                        </xsl:apply-templates>
55                    </xsl:otherwise>
56                </xsl:choose>
57                <xsl:call-template name="index"/>
58            </body>
59        </html>
60    </xsl:template>
61
62    <xsl:template match="dcif:dataCategory[exists(key('value',@isocat:id))]" priority="1" mode="#default"/>
63
64    <xsl:template match="dcif:dataCategory" mode="#all">
65        <xsl:param name="vals" select="()" tunnel="yes"/>
66        <xsl:variable name="dc" select="current()"/>
67        <hr/>
68        <a name="DC-{@isocat:id}"/>
69        <p>
70            <strong>
71                <xsl:value-of select="@isocat:name"/>
72            </strong>
73        </p>
74        <!-- standardized names -->
75        <xsl:for-each-group select=".//dcif:languageSection[dcif:language='en']/dcif:nameSection[dcif:nameStatus='standardized name']" group-by="dcif:name">
76            <div align="left">
77                <i>
78                    <xsl:value-of select="current-grouping-key()"/>
79                </i>
80                <xsl:text>; </xsl:text>
81                <xsl:value-of select="current-group()[1]/dcif:nameStatus"/>
82            </div>
83        </xsl:for-each-group>
84        <!-- preferred names -->
85        <xsl:for-each-group select=".//dcif:languageSection[dcif:language='en']/dcif:nameSection[dcif:nameStatus='preferred name']" group-by="dcif:name">
86            <div align="left">
87                <i>
88                    <xsl:value-of select="current-grouping-key()"/>
89                </i>
90                <xsl:text>; </xsl:text>
91                <xsl:value-of select="current-group()[1]/dcif:nameStatus"/>
92            </div>
93        </xsl:for-each-group>
94        <!-- admitted names -->
95        <xsl:for-each-group select=".//dcif:languageSection[dcif:language='en']/dcif:nameSection[dcif:nameStatus='admitted name']" group-by="dcif:name">
96            <div align="left">
97                <i>
98                    <xsl:value-of select="current-grouping-key()"/>                       
99                </i>
100                <xsl:text>; </xsl:text>
101                <xsl:value-of select="current-group()[1]/dcif:nameStatus"/>
102            </div>
103        </xsl:for-each-group>
104       
105        <xsl:for-each select="tokenize($view-working-languages,'\|')[.!='en']">
106            <xsl:variable name="lang" select="."/>
107            <!-- standardized names -->
108            <xsl:for-each-group select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:nameSection[dcif:nameStatus='standardized name']" group-by="dcif:name">
109                <div align="left">
110                    <i>
111                        <xsl:value-of select="current-grouping-key()"/>
112                    </i>
113                    <xsl:text>; </xsl:text>
114                    <xsl:value-of select="current-group()[1]/dcif:nameStatus"/>
115                    <xsl:text> (</xsl:text>
116                    <xsl:value-of select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:language/@isocat:name"/>
117                    <xsl:text>)</xsl:text>
118                </div>
119            </xsl:for-each-group>
120            <!-- preferred names -->
121            <xsl:for-each-group select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:nameSection[dcif:nameStatus='preferred name']" group-by="dcif:name">
122                <div align="left">
123                    <i>
124                        <xsl:value-of select="current-grouping-key()"/>
125                    </i>
126                    <xsl:text>; </xsl:text>
127                    <xsl:value-of select="current-group()[1]/dcif:nameStatus"/>
128                    <xsl:text> (</xsl:text>
129                    <xsl:value-of select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:language/@isocat:name"/>
130                    <xsl:text>)</xsl:text>
131                </div>
132            </xsl:for-each-group>
133            <!-- admitted names -->
134            <xsl:for-each-group select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:nameSection[dcif:nameStatus='admitted name']" group-by="dcif:name">
135                <div align="left">
136                    <i>
137                        <xsl:value-of select="current-grouping-key()"/>                       
138                    </i>
139                    <xsl:text>; </xsl:text>
140                    <xsl:value-of select="current-group()[1]/dcif:nameStatus"/>
141                    <xsl:text> (</xsl:text>
142                    <xsl:value-of select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:language/@isocat:name"/>
143                    <xsl:text>)</xsl:text>
144                </div>
145            </xsl:for-each-group>
146        </xsl:for-each>
147
148        <!-- Data Element Names -->
149        <xsl:for-each-group select=".//dcif:dataElementNameSection" group-by="dcif:dataElementName">
150            <div align="left">
151                <i>
152                    <xsl:value-of select="current-grouping-key()"/>
153                </i>
154                <xsl:text>; </xsl:text>
155                <xsl:choose>
156                    <xsl:when test="count(current-group()) = 1">
157                        <xsl:text>Source: </xsl:text>
158                    </xsl:when>
159                    <xsl:otherwise>
160                        <xsl:text>Source(s): </xsl:text>
161                    </xsl:otherwise>
162                </xsl:choose>
163                <xsl:value-of select="string-join(current-group()/dcif:source,', ')"/>
164                <xsl:text>; data element name</xsl:text>
165            </div>
166        </xsl:for-each-group>
167
168        <!-- PID -->
169        <p align="left">
170            <xsl:text>PID: </xsl:text>
171            <a href="{@pid}">
172                <xsl:value-of select="@pid"/>
173            </a>
174        </p>
175        <!-- identifier -->
176        <p align="left">
177            <xsl:text>Identifier: </xsl:text>
178            <xsl:value-of select="@isocat:identifier"/>
179            <xsl:text>&#160;&#160;&#160;</xsl:text>
180            <!-- type -->
181            <xsl:text>Type: </xsl:text>
182            <xsl:value-of select="@type"/>
183            <xsl:if test="@type!=@isocat:type">
184                <xsl:text>/</xsl:text>
185                <xsl:value-of select="@isocat:type"/>
186            </xsl:if>
187            <xsl:text>&#160;&#160;&#160;</xsl:text>
188            <!-- origin -->
189            <xsl:text>Origin: </xsl:text>
190            <xsl:value-of select=".//dcif:origin"/>
191            <xsl:text>&#160;&#160;&#160;</xsl:text>
192            <!-- profile(s) -->
193            <xsl:choose>
194                <xsl:when test="count(.//dcif:descriptionSection/dcif:profile) le 1">
195                    <xsl:text>Profile: </xsl:text>
196                    <xsl:value-of select=".//dcif:descriptionSection/dcif:profile"/>
197                </xsl:when>
198                <xsl:when test="count(.//dcif:descriptionSection/dcif:profile) gt 1">
199                    <xsl:text>Profiles: </xsl:text>
200                    <xsl:value-of select="string-join(.//dcif:descriptionSection/dcif:profile,', ')"/>
201                </xsl:when>
202            </xsl:choose>
203        </p>
204        <!-- is-a -->
205        <xsl:if test="@type='simple' and exists(dcif:isA)">
206            <p align="left">
207                <xsl:text>Is a: </xsl:text>
208                <xsl:choose>
209                    <xsl:when test="dcif:isA/@isocat:suppress='true'">
210                        <xsl:value-of select="dcif:isA/@isocat:name"/>
211                    </xsl:when>
212                    <xsl:otherwise>
213                        <a href="#DC-{dcif:isA/@isocat:id}">
214                            <xsl:value-of select="dcif:isA/@isocat:name"/>
215                        </a>
216                    </xsl:otherwise>
217                </xsl:choose>
218            </p>
219        </xsl:if>
220        <!-- definition(s) -->
221        <xsl:for-each select=".//dcif:languageSection[dcif:language='en']/dcif:definitionSection[normalize-space(dcif:definition)!='']">
222            <p align="left">
223                <xsl:text>Definition: </xsl:text>
224                <xsl:value-of select="normalize-space(dcif:definition)"/>
225                <br/>
226                <xsl:text>Source: </xsl:text>
227                <xsl:value-of select="dcif:source"/>
228                <xsl:for-each select="dcif:note[normalize-space(.)!='']">
229                    <br/>
230                    <xsl:text>Note: </xsl:text>
231                    <xsl:value-of select="."/>
232                </xsl:for-each>
233            </p>
234        </xsl:for-each>
235        <!-- examples -->
236        <xsl:for-each select=".//dcif:languageSection[dcif:language='en']/dcif:exampleSection[normalize-space(dcif:example)!='']">
237            <p align="left">
238                <xsl:text>Example: </xsl:text>
239                <xsl:value-of select="normalize-space(dcif:example)"/>
240                <br/>
241                <xsl:text>Source: </xsl:text>
242                <xsl:value-of select="dcif:source"/>
243            </p>
244        </xsl:for-each>
245        <!-- explanations -->
246        <xsl:for-each select=".//dcif:languageSection[dcif:language='en']/dcif:explanationSection[normalize-space(dcif:explanation)!='']">
247            <p align="left">
248                <xsl:text>Explanation: </xsl:text>
249                <xsl:value-of select="normalize-space(dcif:explanation)"/>
250                <br/>
251                <xsl:text>Source: </xsl:text>
252                <xsl:value-of select="dcif:source"/>
253            </p>
254        </xsl:for-each>
255        <!-- notes -->
256        <xsl:for-each select=".//dcif:languageSection[dcif:language='en']/dcif:note[normalize-space(.)!='']">
257            <p align="left">
258                <xsl:text>Note: </xsl:text>
259                <xsl:value-of select="."/>
260            </p>
261        </xsl:for-each>
262       
263        <p align="left">
264            <xsl:text>License: </xsl:text>
265            <xsl:text>This work by </xsl:text>
266            <a xmlns:cc="http://creativecommons.org/ns#" href="{@pid}" property="cc:attributionName" rel="cc:attributionURL">
267                <xsl:value-of select="@pid"/>
268            </a>
269            <xsl:text> is licensed under a </xsl:text>
270            <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>
271            <xsl:text>.</xsl:text>
272        </p>
273       
274        <xsl:for-each select="tokenize($view-working-languages,'\|')[.!='en']">
275            <xsl:variable name="lang" select="."/>
276            <!-- definition(s) -->
277            <xsl:for-each select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:definitionSection[normalize-space(dcif:definition)!='']">
278                <p align="left">
279                    <xsl:value-of select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:language/@isocat:name"/>
280                    <xsl:text> definition: </xsl:text>
281                    <xsl:value-of select="normalize-space(dcif:definition)"/>
282                    <br/>
283                    <xsl:text>Source: </xsl:text>
284                    <xsl:value-of select="dcif:source"/>
285                    <xsl:for-each select="dcif:note[normalize-space(.)!='']">
286                        <br/>
287                        <xsl:text>Note: </xsl:text>
288                        <xsl:value-of select="."/>
289                    </xsl:for-each>
290                </p>
291            </xsl:for-each>
292            <!-- examples -->
293            <xsl:for-each select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:exampleSection[normalize-space(dcif:example)!='']">
294                <p align="left">
295                    <xsl:value-of select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:language/@isocat:name"/>
296                    <xsl:text> example: </xsl:text>
297                    <xsl:value-of select="normalize-space(dcif:example)"/>
298                    <br/>
299                    <xsl:text>Source: </xsl:text>
300                    <xsl:value-of select="dcif:source"/>
301                </p>
302            </xsl:for-each>
303            <!-- explanations -->
304            <xsl:for-each select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:explanationSection[normalize-space(dcif:explanation)!='']">
305                <p align="left">
306                    <xsl:value-of select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:language/@isocat:name"/>
307                    <xsl:text> explanation: </xsl:text>
308                    <xsl:value-of select="normalize-space(dcif:explanation)"/>
309                    <br/>
310                    <xsl:text>Source: </xsl:text>
311                    <xsl:value-of select="dcif:source"/>
312                </p>
313            </xsl:for-each>
314            <!-- notes -->
315            <xsl:for-each select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:note[normalize-space(.)!='']">
316                <p align="left">
317                    <xsl:value-of select="$dc//dcif:languageSection[dcif:language=$lang]/dcif:language/@isocat:name"/>
318                    <xsl:text> note: </xsl:text>
319                    <xsl:value-of select="."/>
320                </p>
321            </xsl:for-each>
322           
323        </xsl:for-each>   
324       
325        <!-- language sections -->
326        <xsl:if test="exists(.//dcif:languageSection[dcif:language!='en'])">
327            <p align="left">
328                <xsl:text>Language sections: </xsl:text>
329                <xsl:value-of select="string-join(.//dcif:languageSection/dcif:language/@isocat:name,', ')"/>
330            </p>
331        </xsl:if>
332
333        <!-- linguistic sections -->
334        <xsl:if test="exists(.//dcif:linguisticSection)">
335            <p align="left">
336                <xsl:text>Linguistic sections: </xsl:text>
337                <xsl:value-of select="string-join(.//dcif:linguisticSection/dcif:language/@isocat:name,', ')"/>
338            </p>
339        </xsl:if>
340
341        <xsl:choose>
342            <xsl:when test="@isocat:type='simple'">
343                <xsl:if test="exists($vals)">
344                    <xsl:for-each select="key('isa',current()/@isocat:id)/ancestor::dcif:dataCategory[exists(index-of($vals,@isocat:id))]">
345                        <blockquote>
346                            <xsl:comment>Keep the blockquote alive.</xsl:comment>
347                            <xsl:apply-templates select="current()" mode="vals">
348                                <xsl:with-param name="vals" select="$vals" tunnel="yes"/>
349                            </xsl:apply-templates>
350                        </blockquote>
351                    </xsl:for-each>
352                </xsl:if>
353            </xsl:when>
354            <xsl:when test="@type='complex'">
355                <!-- data type -->
356                <p align="left">
357                    <xsl:text>Data type: </xsl:text>
358                    <xsl:value-of select="(./dcif:conceptualDomain/dcif:dataType)[1]"/>
359                </p>
360                <xsl:choose>
361                    <xsl:when test="@isocat:type='closed'">
362                        <!-- simple DCs in the value domain and in the DCS -->
363                        <xsl:variable name="vals" select="distinct-values(.//dcif:conceptualDomain/dcif:value/@isocat:id)"/>
364                        <blockquote>
365                            <xsl:comment>Keep the blockquote alive.</xsl:comment>
366                            <xsl:for-each select="key('dc',$vals)[empty(dcif:isA) or empty(key('dc',dcif:isA/@isocat:id))]">
367                                <xsl:apply-templates select="current()" mode="vals">
368                                    <xsl:with-param name="vals" select="$vals" tunnel="yes"/>
369                                </xsl:apply-templates>
370                            </xsl:for-each>
371                        </blockquote>
372                    </xsl:when>
373                    <xsl:when test="@isocat:type='constrained'">
374                        <xsl:for-each select="dcif:conceptualDomain">
375                            <xsl:sort select="dcif:ruleType"/>
376                            <p align="left">
377                                <xsl:text>Type: </xsl:text>
378                                <xsl:value-of select="dcif:ruleType"/>
379                                <br/>
380                                <xsl:for-each select="dcif:rule">
381                                    <xsl:text>Rule: </xsl:text>
382                                    <xsl:apply-templates select="node()" mode="xml"/>
383                                    <xsl:value-of select="normalize-space(.)"/>
384                                    <xsl:if test="position()!=last()">
385                                        <br/>
386                                    </xsl:if>
387                                </xsl:for-each>
388                            </p>
389                        </xsl:for-each>
390                    </xsl:when>
391                </xsl:choose>
392            </xsl:when>
393        </xsl:choose>
394       
395    </xsl:template>
396   
397    <xsl:template match="*" mode="xml">
398        <xsl:text>&lt;</xsl:text>
399        <xsl:value-of select="name()"/>
400        <xsl:apply-templates select="@*" mode="#current"/>
401        <xsl:text>&gt;</xsl:text>
402        <xsl:apply-templates mode="#current"/>
403        <xsl:text>&lt;/</xsl:text>
404        <xsl:value-of select="name()"/>
405        <xsl:apply-templates select="@*" mode="#current"/>
406        <xsl:text>&gt;</xsl:text>
407    </xsl:template>
408
409    <xsl:template match="@*" mode="xml">
410        <xsl:text> </xsl:text>
411        <xsl:value-of select="name()"/>
412        <xsl:text>"</xsl:text>
413        <xsl:value-of select="."/>
414        <xsl:text>"</xsl:text>
415    </xsl:template>
416   
417    <xsl:template name="index">
418        <hr/>
419        <a name="index"/>
420        <table>
421            <thead>
422                <tr>
423                    <th/>
424                    <th align="left">Name</th>
425                    <th align="left">type</th>
426                </tr>
427            </thead>
428            <tbody>
429                <xsl:for-each select="dcif:dataCategory">
430                    <xsl:sort select="@isocat:name"/>
431                    <tr>
432                        <td align="right">
433                            <xsl:value-of select="position()"/>
434                        </td>
435                        <td>
436                            <a href="#DC-{@isocat:id}">
437                                <xsl:value-of select="@isocat:name"/>
438                            </a>
439                        </td>
440                        <td>
441                            <xsl:value-of select="@type"/>
442                            <xsl:if test="@type!=@isocat:type">
443                                <xsl:text>/</xsl:text>
444                                <xsl:value-of select="@isocat:type"/>
445                            </xsl:if>
446                        </td>
447                    </tr>
448                </xsl:for-each>
449            </tbody>
450        </table>
451
452    </xsl:template>
453
454</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.