source: ISOcat/trunk/mod-ISOcat-interface-gi/interface/JSXAPPS/ISOcat/xsl/DC2CDF.xsl @ 2029

Last change on this file since 2029 was 2029, checked in by mwindhouwer, 12 years ago

Initial import of all the *cats, i.e., ISOcat, RELcat and SCHEMAcat.

File size: 12.0 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet
3  xmlns:dcif="http://www.isocat.org/ns/dcif"
4  xmlns:isocat="http://www.isocat.org/"
5  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
6  version="1.0"
7>
8
9        <xsl:template match="text()"/>
10       
11        <xsl:template match="dcif:dataCategorySelection">
12                <data jsxid="jsxroot">
13                        <xsl:apply-templates/>
14                </data>
15        </xsl:template>
16       
17        <xsl:template match="dcif:dataCategory">
18                <record jsxid="dc-{@isocat:id}">
19                        <xsl:if test="@isocat:owner_id">
20                                <xsl:attribute name="owner">
21                                        <xsl:value-of select="@isocat:owner_id"/>
22                                </xsl:attribute>
23                        </xsl:if>
24                        <xsl:apply-templates select="dcif:administrationInformationSection"/>
25                        <xsl:apply-templates select="dcif:descriptionSection"/>
26                        <xsl:call-template name="conceptualdomains"/>
27                        <xsl:call-template name="linguisticsections"/>
28                        <xsl:apply-templates select="dcif:isA"/>
29                </record>
30        </xsl:template>
31       
32        <xsl:template match="dcif:administrationInformationSection/dcif:administrationRecord">
33                <record jsxid="admin" type="{ancestor::dcif:dataCategory/@isocat:type}">
34                        <xsl:call-template name="admin"/>
35                        <xsl:call-template name="admin-explanations"/>
36                        <xsl:call-template name="admin-issues"/>
37                        <xsl:call-template name="admin-changes"/>
38                        <xsl:apply-templates/>
39                </record>
40        </xsl:template>
41       
42        <xsl:template name="admin">
43                <xsl:for-each select="
44                    dcif:identifier
45                  | dcif:version
46                  | dcif:registrationStatus
47                  | isocat:administrationStatus
48                  | dcif:justification
49                  | dcif:origin
50                  | dcif:effectiveDate
51                  | dcif:untilDate
52                ">
53                        <xsl:attribute name="{local-name()}">
54                                <xsl:value-of select="."/>
55                        </xsl:attribute>
56                </xsl:for-each>
57        </xsl:template>
58
59        <xsl:template name="admin-explanations">
60                <record jsxid="explanations">
61                        <xsl:for-each select="dcif:explanatoryComment">
62                                <record jsxid="expl-{@isocat:id}" jsxtext="{.}"/>
63                        </xsl:for-each>
64                </record>
65        </xsl:template>
66
67        <xsl:template name="admin-issues">
68                <record jsxid="issues">
69                        <xsl:for-each select="dcif:unresolvedIssue">
70                                <record jsxid="issue-{@isocat:id}" jsxtext="{.}"/>
71                        </xsl:for-each>
72                </record>
73        </xsl:template>
74
75        <xsl:template name="admin-changes">
76                <record jsxid="changes">
77                        <xsl:for-each select="isocat:change">
78                                <record jsxid="change-{@isocat:id}" jsxtext="{.}" timestamp="{@timestamp}"/>
79                        </xsl:for-each>
80                </record>
81        </xsl:template>
82
83        <xsl:template match="dcif:descriptionSection">
84                <record jsxid="descr">
85                        <xsl:call-template name="descr-profiles"/>
86                        <xsl:call-template name="descr-datanames"/>
87                        <xsl:call-template name="descr-languagesections"/>
88                </record>
89        </xsl:template>
90
91        <xsl:template name="descr-profiles">
92                <record jsxid="profiles">
93                        <xsl:for-each select="dcif:profile">
94                                <record jsxid="profile-{@isocat:id}" jsxtext="{.}"/>                           
95                        </xsl:for-each>
96                </record>
97        </xsl:template>
98       
99        <xsl:template name="descr-datanames">
100                <record jsxid="datanames">
101                        <xsl:for-each select="dcif:dataElementNameSection">
102                                <record jsxid="dataname-{@isocat:id}" jsxtext="{dcif:dataElementName}" source="{dcif:source}"/>
103                        </xsl:for-each>
104                </record>
105        </xsl:template>
106       
107        <xsl:template name="descr-languagesections">
108                <record jsxid="languagesections">
109                        <xsl:for-each select="dcif:languageSection">
110                                <record jsxid="languagesection-{@isocat:id}" jsxtext="{dcif:language}" language="language-{dcif:language/@isocat:id}">
111                                        <xsl:call-template name="langsec-names">
112                                                <xsl:with-param name="lang" select="dcif:language"/>
113                                        </xsl:call-template>
114                                        <xsl:call-template name="langsec-definitions">
115                                                <xsl:with-param name="lang" select="dcif:language"/>
116                                        </xsl:call-template>
117                                        <xsl:call-template name="langsec-examples">
118                                                <xsl:with-param name="lang" select="dcif:language"/>
119                                        </xsl:call-template>
120                                        <xsl:call-template name="langsec-explanations">
121                                                <xsl:with-param name="lang" select="dcif:language"/>
122                                        </xsl:call-template>
123                                        <xsl:call-template name="langsec-notes">
124                                                <xsl:with-param name="lang" select="dcif:language"/>
125                                        </xsl:call-template>
126                                </record>
127                        </xsl:for-each>
128                </record>
129        </xsl:template>
130       
131        <xsl:template name="langsec-names">
132                <xsl:param name="lang"/>
133                <record jsxid="names-{$lang}">
134                        <xsl:for-each select="dcif:nameSection">
135                                <record jsxid="name-{@isocat:id}" jsxtext="{dcif:name}" status="{dcif:nameStatus}"/>
136                        </xsl:for-each>
137                </record>
138        </xsl:template>
139       
140        <xsl:template name="langsec-definitions">
141                <xsl:param name="lang"/>
142                <record jsxid="definitions-{$lang}">
143                        <xsl:for-each select="dcif:definitionSection">
144                                <record jsxid="definition-{@isocat:id}" jsxtext="{dcif:definition}" source="{dcif:source}" note="{dcif:note}"/>
145                        </xsl:for-each>
146                </record>
147        </xsl:template>
148       
149        <xsl:template name="langsec-examples">
150                <xsl:param name="lang"/>
151                <record jsxid="examples-{$lang}">
152                        <xsl:for-each select="dcif:exampleSection">
153                                <record jsxid="example-{@isocat:id}" jsxtext="{dcif:example}" source="{dcif:source}"/>
154                        </xsl:for-each>
155                </record>
156        </xsl:template>
157
158        <xsl:template name="langsec-explanations">
159                <xsl:param name="lang"/>
160                <record jsxid="explanations-{$lang}">
161                        <xsl:for-each select="dcif:explanationSection">
162                                <record jsxid="explanation-{@isocat:id}" jsxtext="{dcif:explanation}" source="{dcif:source}"/>
163                        </xsl:for-each>
164                </record>
165        </xsl:template>
166
167        <xsl:template name="langsec-notes">
168                <xsl:param name="lang"/>
169                <record jsxid="notes-{$lang}">
170                        <xsl:for-each select="dcif:note">
171                                <record jsxid="note-{@isocat:id}" jsxtext="{.}"/>
172                        </xsl:for-each>
173                </record>
174        </xsl:template>
175       
176        <xsl:key name="values" match="dcif:value" use="@isocat:id"/>
177       
178        <xsl:template name="conceptualdomains">
179                <xsl:variable name="type" select="(dcif:conceptualDomain/@type)[1]"/>
180                <record jsxid="conceptualdomain" type="{$type}">
181                        <!-- open, closed and constrained -->
182                        <xsl:variable name="dataType" select="(dcif:conceptualDomain/dcif:dataType)[1]"/>
183                        <xsl:if test="$dataType">
184                                <xsl:attribute name="datatype">
185                                        <xsl:value-of select="$dataType"/>
186                                </xsl:attribute>
187                                <xsl:attribute name="datatype-id">
188                                        <xsl:text>datatype-</xsl:text>
189                                        <xsl:value-of select="$dataType/@isocat:id"/>
190                                </xsl:attribute>
191                        </xsl:if>
192                        <!-- open -->
193                        <xsl:if test="$type='open'">
194                                <xsl:attribute name="cd-id">
195                                        <xsl:value-of select="(dcif:conceptualDomain/@isocat:id)[1]"/>
196                                </xsl:attribute>
197                        </xsl:if>
198                        <!-- closed -->
199                        <xsl:for-each select="dcif:conceptualDomain/dcif:value[count(. | key('values', @isocat:id)[1]) = 1]">
200                                <xsl:variable name="val" select="current()"/>
201                                <record jsxid="conceptualdomain-value-{$val/@isocat:id}" jsxtext="{$val/@isocat:name}" name="{$val/@isocat:name}" identifier="{$val/@isocat:identifier}">
202                                        <xsl:for-each select="isocat:profile">
203                                                <xsl:variable name="prof" select="current()"/>
204                                                <xsl:attribute name="profile-{$prof/@isocat:id}-name">
205                                                        <xsl:value-of select="$prof"/>
206                                                </xsl:attribute>
207                                                <xsl:variable name="cd" select="key('values',$val/@isocat:id)/parent::dcif:conceptualDomain[parent::dcif:dataCategory][dcif:profile/@isocat:id=$prof/@isocat:id]"/>
208                                                <xsl:choose>
209                                                        <xsl:when test="$cd">
210                                                                <xsl:attribute name="profile-{$prof/@isocat:id}">1</xsl:attribute>
211                                                                <xsl:attribute name="profile-{$prof/@isocat:id}-cd">
212                                                                        <xsl:value-of select="$cd/@isocat:id"/>
213                                                                </xsl:attribute>
214                                                        </xsl:when>
215                                                        <xsl:otherwise>
216                                                                <xsl:attribute name="profile-{$prof/@isocat:id}">0</xsl:attribute>
217                                                        </xsl:otherwise>
218                                                </xsl:choose>
219                                        </xsl:for-each>
220                                        <!-- special for profile-0, i.e., the Private profile: the DC might be in the private profile value domain, although it isn't a member of the private profile -->
221                                        <xsl:choose>
222                                                <xsl:when test="isocat:profile[@isocat:id='0']">
223                                                        <!-- don't do anything, handled above -->
224                                                        <xsl:message>simple DC is a member of the Private profile</xsl:message>
225                                                </xsl:when>
226                                                <xsl:when test="key('values',$val/@isocat:id)/parent::dcif:conceptualDomain[parent::dcif:dataCategory][dcif:profile/@isocat:id='0']">
227                                                        <!-- part of the private profile value domain -->
228                                                        <xsl:message>simple DC is part of the Private profile value domain</xsl:message>
229                                                        <xsl:attribute name="profile-0">1</xsl:attribute>
230                                                        <xsl:attribute name="profile-0-name">
231                                                                <xsl:text>Private</xsl:text>
232                                                        </xsl:attribute>
233                                                        <xsl:attribute name="profile-0-cd">
234                                                                <xsl:value-of select="key('values',$val/@isocat:id)/parent::dcif:conceptualDomain[parent::dcif:dataCategory][dcif:profile/@isocat:id='0']/@isocat:id"/>
235                                                        </xsl:attribute>
236                                                </xsl:when>
237                                                <!-- there is no private profile value domain, and the simple DC isn't a member of the private profile --> 
238                                        </xsl:choose>
239                                </record>
240                        </xsl:for-each>
241                        <!-- constrained -->
242                        <xsl:for-each select="dcif:conceptualDomain/dcif:rule">
243                                <!-- keep also track of the conceptual domain id -->
244                                <record jsxid="conceptualdomain-rule-{@isocat:id}" rule-type="{../dcif:ruleType}" rule-type-id="rule-type-{../dcif:ruleType/@isocat:id}" cd-id="cd-{parent::dcif:conceptualDomain/@isocat:id}" jsxtext="{.}"/>
245                        </xsl:for-each>
246                </record>
247        </xsl:template>
248
249        <xsl:template match="dcif:isA">
250                <record jsxid="is-a" id="{@isocat:id}" jsxtext="{@isocat:name}" name="{@isocat:name}" identifier="{@isocat:identifier}"/>
251        </xsl:template> 
252
253        <xsl:template name="linguisticsections">
254                <record jsxid="linguisticsections">
255                        <xsl:for-each select="dcif:linguisticSection">
256                                <record jsxid="linguisticsection-{@isocat:id}" jsxtext="{dcif:language}" language="language-{dcif:language/@isocat:id}" type="{@type}">
257                                        <xsl:call-template name="lingsec-examples">
258                                                <xsl:with-param name="lang" select="dcif:language"/>
259                                        </xsl:call-template>
260                                        <xsl:call-template name="lingsec-explanations">
261                                                <xsl:with-param name="lang" select="dcif:language"/>
262                                        </xsl:call-template>
263                                        <xsl:call-template name="lingsec-notes">
264                                                <xsl:with-param name="lang" select="dcif:language"/>
265                                        </xsl:call-template>
266                                        <xsl:call-template name="lingsec-conceptualdomains">
267                                                <xsl:with-param name="lang" select="dcif:language"/>
268                                        </xsl:call-template>
269                                </record>
270                        </xsl:for-each>
271                </record>
272        </xsl:template>
273
274        <xsl:template name="lingsec-examples">
275                <xsl:param name="lang"/>
276                <record jsxid="lingsec-examples-{$lang}">
277                        <xsl:for-each select="dcif:exampleSection">
278                                <record jsxid="example-{@isocat:id}" jsxtext="{dcif:example}" source="{dcif:source}"/>
279                        </xsl:for-each>
280                </record>
281        </xsl:template>
282       
283        <xsl:template name="lingsec-explanations">
284                <xsl:param name="lang"/>
285                <record jsxid="lingsec-explanations-{$lang}">
286                        <xsl:for-each select="dcif:explanationSection">
287                                <record jsxid="explanation-{@isocat:id}" jsxtext="{dcif:explanation}" source="{dcif:source}"/>
288                        </xsl:for-each>
289                </record>
290        </xsl:template>
291       
292        <xsl:template name="lingsec-notes">
293                <xsl:param name="lang"/>
294                <record jsxid="lingsec-notes-{$lang}">
295                        <xsl:for-each select="dcif:note">
296                                <record jsxid="note-{@isocat:id}" jsxtext="{.}"/>
297                        </xsl:for-each>
298                </record>
299        </xsl:template>
300       
301        <xsl:template name="lingsec-conceptualdomains">
302                <xsl:param name="lang"/>
303                <xsl:variable name="type" select="(dcif:conceptualDomain/@type)[1]"/>
304                <record jsxid="lingsec-conceptualdomain-{$lang}" type="{$type}">
305                        <!-- closed -->
306                        <xsl:for-each select="dcif:conceptualDomain/dcif:value">
307                                <record jsxid="lingsec-conceptualdomain-{$lang}-value-{@isocat:id}"  cd-id="cd-{parent::dcif:conceptualDomain/@isocat:id}" jsxtext="{@isocat:name}" name="{@isocat:name}" identifier="{@isocat:identifier}"/>
308                        </xsl:for-each>
309                        <!-- constrained -->
310                        <xsl:for-each select="dcif:conceptualDomain/dcif:rule">
311                                <record jsxid="lingsec-conceptualdomain-{$lang}-rule-{@isocat:id}" rule-type="{../dcif:ruleType}" rule-type-id="rule-type-{../dcif:ruleType/@isocat:id}" cd-id="cd-{parent::dcif:conceptualDomain/@isocat:id}" jsxtext="{.}"/>
312                        </xsl:for-each>
313                </record>
314        </xsl:template>
315       
316</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.