comparison DVN-web/installer/dvninstall/config/mif2ddi.xsl @ 6:1b2188262ae9

adding the installer.
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Wed, 13 May 2015 11:50:21 +0200
parents
children
comparison
equal deleted inserted replaced
5:dd9adfc73390 6:1b2188262ae9
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.icpsr.umich.edu/DDI" xmlns:a="http://www.thedataweb.org/mif" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="a">
3 <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
4 <xsl:strip-space elements="*"/>
5 <xsl:param name="schemaLocation">http://www.icpsr.umich.edu/DDI/Version1-3.xsd</xsl:param>
6 <xsl:param name="fileDscrId" select="concat('ID',generate-id())"/>
7 <!-- *** -->
8 <!-- Default Template to start processng of MIF Document -->
9 <!-- *** -->
10 <xsl:template match="/">
11 <xsl:choose>
12 <xsl:when test="a:mifSet">
13 <xsl:apply-templates select="a:mifSet/a:mif[position() = 1]"/>
14 <!-- TODO: Deal with multiple docs in a mifset-->
15 </xsl:when>
16 <xsl:otherwise>
17 <xsl:apply-templates select="a:mif"/>
18 </xsl:otherwise>
19 </xsl:choose>
20 </xsl:template>
21
22 <xsl:template match="a:mif">
23 <!-- Nest all in a codebook element -->
24 <xsl:element name="codeBook" namespace="http://www.icpsr.umich.edu/DDI">
25 <xsl:attribute name="xsi:schemaLocation"><xsl:text>http://www.icpsr.umich.edu/DDI </xsl:text>
26 <xsl:value-of select="$schemaLocation"/></xsl:attribute>
27 <docDscr>
28 <citation>
29 <xsl:call-template name="titlStmt"/>
30 <xsl:if test="normalize-space(a:documentDescription/a:producer) != '' or normalize-space(a:documentDescription/a:producer/@prodDate) != ''">
31 <prodStmt>
32 <xsl:if test="normalize-space(a:documentDescription/a:producer) != ''">
33 <producer>
34 <xsl:value-of select="normalize-space(a:documentDescription/a:producer)"/>
35 </producer>
36 </xsl:if>
37 <xsl:if test="normalize-space(a:documentDescription/a:producer/@prodDate) != ''">
38 <prodDate>
39 <xsl:attribute name="date"><xsl:value-of select="normalize-space(a:documentDescription/a:producer/@prodDate)"/></xsl:attribute>
40 </prodDate>
41 </xsl:if>
42 </prodStmt>
43 </xsl:if>
44 <distStmt>
45 <!-- We are adding this temporarily. Census should provide this information in the MIF. -->
46 <distrbtr>
47 <ExtLink URI="http://www.thedataweb.org/images/ferrett_dataweb.jpg" title="Logo" role="image"/>
48 U.S. Census Bureau
49 <ExtLink URI="http://www.thedataweb.org/index.html" title="URL"/>
50 </distrbtr>
51 </distStmt>
52 <xsl:if test="normalize-space(a:documentDescription/a:version/@versionnum) != ''">
53 <verStmt>
54 <version>
55 <xsl:attribute name="date"><xsl:value-of select="normalize-space(a:documentDescription/a:version/@modDate)"/></xsl:attribute>
56 <xsl:value-of select="normalize-space(a:documentDescription/a:version/@versionnum)"/>
57 </version>
58 </verStmt>
59 </xsl:if>
60 <!-- Add holdings for all studies from thedataweb -->
61 <holdings URI="http://www.thedataweb.org"/>
62 </citation>
63 </docDscr>
64 <stdyDscr>
65 <citation>
66 <xsl:call-template name="titlStmt"/>
67 <xsl:if test="normalize-space(a:dataSet/a:providerInfo) != '' and (normalize-space(a:dataSet/a:providerInfo/@name) != 0 or normalize-space(a:dataSet/a:providerInfo/@name) != '' )">
68 <rspStmt>
69 <AuthEnty>
70 <xsl:value-of select="normalize-space(a:dataSet/a:providerInfo/@name)"/>
71 <xsl:text>:</xsl:text>
72 <xsl:value-of select="normalize-space(a:dataSet/a:providerInfo)"/>
73 </AuthEnty>
74 </rspStmt>
75 </xsl:if>
76 <xsl:if test="normalize-space(a:dataSet/a:sponsorInfo/@name) != '' or normalize-space(a:dataSet/a:sponsorInfo/@imageUrl) != '' or normalize-space(a:dataSet/a:sponsorInfo/@homepageUrl) != ''">
77 <distStmt>
78 <distrbtr>
79 <xsl:if test="normalize-space(a:dataSet/a:sponsorInfo/@imageUrl) != ''">
80 <ExtLink title="Logo" role="image">
81 <xsl:attribute name="URI"><xsl:value-of select="normalize-space(a:dataSet/a:sponsorInfo/@imageUrl)"/></xsl:attribute>
82 </ExtLink>
83 </xsl:if>
84 <xsl:value-of select="normalize-space(a:dataSet/a:sponsorInfo/@name)"/>
85 <xsl:if test="normalize-space(a:dataSet/a:sponsorInfo/@homepageUrl) != ''">
86 <ExtLink title="URL">
87 <xsl:attribute name="URI"><xsl:value-of select="normalize-space(a:dataSet/a:sponsorInfo/@homepageUrl)"/></xsl:attribute>
88 </ExtLink>
89 </xsl:if>
90 </distrbtr>
91 </distStmt>
92 </xsl:if>
93 </citation>
94 <stdyInfo>
95 <subject>
96 <topcClas source="archive" vocab="TheDataWeb">TheDataWeb</topcClas>
97 <!-- TODO: Grab variable concepts and put them here -->
98 </subject>
99 <xsl:if test="normalize-space(a:dataSet/a:abstract) != ''">
100 <abstract>
101 <xsl:value-of select="a:dataSet/a:abstract"/>
102 </abstract>
103 </xsl:if>
104 <xsl:if test="normalize-space(a:dataSet/a:collectDate/@end) != '' or normalize-space(a:dataSet/a:collectDate/@start) != '' or normalize-space(a:dataSet/a:category) != '' ">
105 <sumDscr>
106 <xsl:if test="normalize-space(a:dataSet/a:collectDate/@end) != '' or normalize-space(a:dataSet/a:collectDate/@start) != ''">
107 <collDate>
108 <xsl:attribute name="date"><xsl:value-of select="normalize-space(a:dataSet/a:collectDate/@start)"/></xsl:attribute>
109 <xsl:attribute name="event">start</xsl:attribute>
110 </collDate>
111 <collDate>
112 <xsl:attribute name="date"><xsl:value-of select="normalize-space(a:dataSet/a:collectDate/@end)"/></xsl:attribute>
113 <xsl:attribute name="event">end</xsl:attribute>
114 </collDate>
115 </xsl:if>
116 <xsl:if test="normalize-space(a:dataSet/a:category) != ''">
117 <dataKind>
118 <xsl:value-of select="normalize-space(a:dataSet/a:category)"/>
119 </dataKind>
120 </xsl:if>
121 </sumDscr>
122 </xsl:if>
123 </stdyInfo>
124
125 <!-- The original MIFs should have some text in restrictions explaining where to get the data. -->
126
127 <xsl:if test="normalize-space(a:dataSet/a:restriction/@originaluri) != ''">
128 <dataAccs>
129 <useStmt>
130 <specPerm>
131 <xsl:attribute name="URI"><xsl:value-of select="normalize-space(a:dataSet/a:restriction/@originaluri)"/></xsl:attribute>
132 You must agree to the terms and conditions described here: <xsl:value-of select="normalize-space(a:dataSet/a:restriction/@originaluri)"/></specPerm>
133 </useStmt>
134 </dataAccs>
135 </xsl:if>
136
137 </stdyDscr>
138 <xsl:if test="a:dataSet/a:extractionHost">
139 <fileDscr>
140 <xsl:attribute name="ID"><xsl:value-of select="$fileDscrId"/></xsl:attribute>
141 <xsl:attribute name="URI">
142 <!-- TODO: Add virtualid match for round-tripping -->
143 <!-- TODO: Need to url-encode these -->
144 <!-- TODO: Need to add port-->
145 <xsl:value-of select="a:dataSet/a:extractionHost/@uri"/>
146 <xsl:text>/TheDataWeb_Tabulation/VDCRepositoryServlet/</xsl:text>
147 <xsl:value-of select="a:dataSet/a:shortName"/>
148 <xsl:text>/</xsl:text>
149 <xsl:value-of select="a:dataSet/a:subsurveyName"/>
150 <xsl:text>/</xsl:text>
151 <xsl:value-of select="a:dataSet/a:component"/>
152 <xsl:text>/</xsl:text>
153 <xsl:value-of select="a:dataSet/a:instance"/>
154 <xsl:text>/</xsl:text>
155 <xsl:value-of select="a:dataSet/a:extractionHost/@type"/>
156 </xsl:attribute>
157 <fileTxt>
158 <fileName>Data File</fileName>
159 <fileCont><xsl:value-of select="a:dataSet/a:longName"/></fileCont>
160 </fileTxt>
161 </fileDscr>
162 </xsl:if>
163 <xsl:apply-templates select="a:variables"/>
164 </xsl:element>
165 </xsl:template>
166 <!-- ********************************************************************************************************************************-->
167 <!-- *** Variables Template: matches variable section of MIF Document ***-->
168 <!-- ********************************************************************************************************************************-->
169 <xsl:template match="a:variables">
170 <dataDscr>
171 <xsl:apply-templates select="a:var"/>
172 </dataDscr>
173 </xsl:template>
174 <!-- ********************************************************************************************************************************-->
175 <!-- *** Variable Template: transforms each MIF Variable to a DDI Variable ***-->
176 <!-- ********************************************************************************************************************************-->
177 <xsl:template match="a:var">
178 <var>
179 <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
180 <xsl:attribute name="ID"><xsl:value-of select="@id"/></xsl:attribute>
181 <xsl:if test="./a:type/@isweight = 'Y'">
182 <xsl:attribute name="wgt">wgt</xsl:attribute>
183 </xsl:if>
184 <xsl:if test="./a:type/@weightvar">
185 <xsl:attribute name="wgt-var"><xsl:value-of select="./a:type/@weightvar"/></xsl:attribute>
186 </xsl:if>
187 <xsl:if test="./a:type/@decimal and ./a:type/@decimal > 0">
188 <xsl:attribute name="dcml"><xsl:value-of select="./a:type/@decimal"/></xsl:attribute>
189 </xsl:if>
190 <xsl:if test="./a:type/@datatype and ./a:type/@decimal">
191 <xsl:attribute name="intrvl"><xsl:choose>
192 <xsl:when test="(./a:type/@datatype = 'numeric' or ./a:type/@datatype = 'impliedDecimal') and ./a:type/@decimal > 0 ">contin</xsl:when>
193 <xsl:when test="./a:type/@datatype = 'numeric' and ./a:type/@decimal = 0 and ./a:values">discrete</xsl:when>
194 <xsl:otherwise>contin</xsl:otherwise>
195 </xsl:choose></xsl:attribute>
196 </xsl:if>
197 <location fileid="{$fileDscrId}"/>
198 <xsl:apply-templates select="a:label"/>
199 <xsl:apply-templates select="a:security"/>
200 <xsl:apply-templates select="a:values"/>
201 <xsl:apply-templates select="a:universe"/>
202 <!--xsl:apply-templates select="a:longDscr"/-->
203 <!--xsl:apply-templates select="a:type/a:categories/a:catValu"/-->
204 <!--xsl:apply-templates select="a:concept"/-->
205 <!-- DDI MAPPING NOTE: codeBook/stdyDescr/var/varFormat, var[-->
206 <varFormat>
207 <xsl:attribute name="type">
208 <xsl:choose>
209 <xsl:when test="./a:type[@datatype='floatingPoint']">numeric</xsl:when>
210 <xsl:when test="./a:type[@datatype='numeric']">numeric</xsl:when>
211 <xsl:when test="./a:type[@datatype='impliedDecimal']">numeric</xsl:when>
212 <xsl:otherwise>character</xsl:otherwise>
213 </xsl:choose>
214 </xsl:attribute>
215 <xsl:attribute name="formatname"><xsl:value-of select="./a:type[@datatype]"/></xsl:attribute>
216 <xsl:attribute name="schema">other</xsl:attribute>
217 </varFormat>
218 <xsl:apply-templates select="a:period"/>
219 <xsl:apply-templates select="a:attachment"/>
220 <xsl:apply-templates select="a:synonyms"/>
221 </var>
222 </xsl:template>
223 <xsl:template match="a:synonyms">
224 <xsl:for-each select="a:synonym">
225 <notes type="mif/variables/var/synonyms/synonym">
226 <xsl:value-of select="."/>
227 </notes>
228 </xsl:for-each>
229 </xsl:template>
230 <xsl:template match="a:attachment">
231 <notes type="mif/variables/var/attachment[{position()}]/@type">
232 <xsl:value-of select="@type"/>
233 </notes>
234 <notes type="mif/variables/var/attachment[{position()}]/@title">
235 <xsl:value-of select="@title"/>
236 </notes>
237 <notes type="mif/variables/var/attachment[{position()}]/@uri">
238 <xsl:value-of select="@uri"/>
239 </notes>
240 <notes type="mif/variables/var/attachment[{position()}]/text()">
241 <xsl:value-of select="."/>
242 </notes>
243 </xsl:template>
244 <!-- ********************************************************************************************************************************-->
245 <!-- *** Long Description Template ***-->
246 <!-- ********************************************************************************************************************************-->
247 <xsl:template match="a:longDscr">
248 <xsl:if test=". != ''">
249 <txt>
250 <xsl:value-of select="."/>
251 </txt>
252 </xsl:if>
253 </xsl:template>
254 <!-- ********************************************************************************************************************************-->
255 <!-- *** values Templates ***-->
256 <!-- ********************************************************************************************************************************-->
257 <xsl:template match="a:values">
258 <xsl:variable name="iNodes" select="count(a:item)"/>
259 <xsl:variable name="rNodes" select="count(a:range)"/>
260
261 <xsl:if test="$rNodes > 0 or $iNodes > 0">
262 <valrng>
263 <xsl:if test="$rNodes > 0">
264 <xsl:apply-templates select="a:range" mode="range"/>
265 </xsl:if>
266 <xsl:if test="$iNodes > 0">
267 <xsl:apply-templates select="a:item" mode="items"/>
268 </xsl:if>
269 <xsl:if test="$rNodes > 0">
270 <key><xsl:text>&#xA;</xsl:text>
271 <xsl:apply-templates select="a:range" mode="rkey"/>
272 </key>
273 </xsl:if>
274
275 </valrng>
276 </xsl:if>
277 <xsl:if test="$iNodes > 0">
278 <xsl:apply-templates select="a:item" mode="categry"/>
279 </xsl:if>
280 </xsl:template>
281
282
283 <xsl:template match="a:range" mode="range">
284 <range>
285 <xsl:attribute name="min"><xsl:value-of select="./@min"/></xsl:attribute>
286 <xsl:attribute name="max"><xsl:value-of select="./@max"/></xsl:attribute>
287 <!-- xsl:value-of select="."/ -->
288 </range>
289 <!-- notes>
290 <xsl:value-of select="normalize-space(.)"/>
291 </notes -->
292 </xsl:template>
293
294 <xsl:template match="a:item" mode="items">
295 <item>
296 <xsl:attribute name="VALUE"><xsl:value-of select="./@value"/></xsl:attribute>
297 </item>
298 </xsl:template>
299
300
301 <xsl:template match="a:range" mode="rkey">
302 <xsl:text>(</xsl:text><xsl:value-of select="./@min"/><xsl:text>-</xsl:text><xsl:value-of select="./@max"/><xsl:text>) = (</xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>)&#xA;</xsl:text>
303 </xsl:template>
304
305 <xsl:template match="a:item" mode="categry">
306 <catgry>
307 <xsl:if test="./@missing">
308 <xsl:attribute name="missing"><xsl:choose><xsl:when test="./@missing = 'Y'">Y</xsl:when><xsl:otherwise>N</xsl:otherwise></xsl:choose></xsl:attribute>
309 </xsl:if>
310 <catValu>
311 <xsl:value-of select="./@value"/>
312 </catValu>
313 <labl>
314 <xsl:value-of select="normalize-space(.)"/>
315 </labl>
316 <xsl:if test="./@count">
317 <catStat type="freq">
318 <xsl:value-of select="./@count"/>
319 </catStat>
320 </xsl:if>
321 </catgry>
322 </xsl:template>
323
324
325 <!-- ********************************************************************************************************************************-->
326 <!-- *** Universe Template ***-->
327 <!-- ********************************************************************************************************************************-->
328 <xsl:template match="a:universe">
329 <universe>
330 <xsl:if test=". != ''">
331 <txt>
332 <xsl:value-of select="normalize-space(.)"/>
333 </txt>
334 </xsl:if>
335 <concept>
336 <xsl:value-of select="./@type"/>
337 </concept>
338 </universe>
339 </xsl:template>
340 <!-- ********************************************************************************************************************************-->
341 <!-- *** Universe Template ***-->
342 <!-- ********************************************************************************************************************************-->
343 <xsl:template match="a:concept">
344 <concept>
345 <xsl:attribute name="vocab"><xsl:value-of select="./@type"/></xsl:attribute>
346 <xsl:value-of select="normalize-space(.)"/>
347 </concept>
348 </xsl:template>
349 <!-- ********************************************************************************************************************************-->
350 <!-- *** Variable Label Template ***-->
351 <!-- ********************************************************************************************************************************-->
352 <xsl:template match="a:label">
353 <labl level="variable">
354 <xsl:value-of select="normalize-space(.)"/>
355 </labl>
356 </xsl:template>
357 <!-- ********************************************************************************************************************************-->
358 <!-- *** Security Template ***-->
359 <!-- ********************************************************************************************************************************-->
360 <xsl:template match="a:security">
361 <security>
362 <xsl:attribute name="date"><xsl:value-of select="./@date"/></xsl:attribute>
363 <xsl:value-of select="./@level"/>
364 </security>
365 </xsl:template>
366 <!-- ********************************************************************************************************************************-->
367 <!-- *** Value Range Template ***-->
368 <!-- ********************************************************************************************************************************-->
369 <!-- ********************************************************************************************************************************-->
370 <!-- *** Variable Period Template ***-->
371 <!-- ********************************************************************************************************************************-->
372 <xsl:template match="a:period">
373 <notes type="mif/variables/var/period/@start">
374 <xsl:value-of select="./@start"/>
375 </notes>
376 <notes type="mif/variables/var/period/@end">
377 <xsl:value-of select="./@end"/>
378 </notes>
379 </xsl:template>
380
381 <xsl:template match="*|@*">
382 <xsl:comment><xsl:call-template name="full-path"/><xsl:value-of select="concat('=',.)"/></xsl:comment>
383 </xsl:template>
384 <!-- ********************************************************************************************************************************-->
385 <!-- *** Title/ handle Template ***-->
386 <!-- ********************************************************************************************************************************-->
387 <xsl:template name="titlStmt">
388 <titlStmt>
389 <titl>
390 <xsl:value-of select="normalize-space(a:dataSet/a:longName)"/>
391 <xsl:if test="normalize-space(a:dataSet/a:shortName) != ''">
392 <xsl:text>(</xsl:text>
393 <xsl:value-of select="normalize-space(a:dataSet/a:shortName)"/>
394 <xsl:text>)</xsl:text>
395 </xsl:if>
396 <xsl:if test="normalize-space(a:dataSet/a:subsurveyName) != ''">
397 <xsl:text>:</xsl:text>
398 <xsl:value-of select="normalize-space(a:dataSet/a:subsurveyName)"/>
399 </xsl:if>
400 <xsl:if test="normalize-space(a:dataSet/a:inheritedComponent) != ''">
401 <xsl:text>:</xsl:text>
402 <xsl:value-of select="normalize-space(a:dataSet/a:inheritedComponent)"/>
403 </xsl:if>
404 <xsl:if test="normalize-space(a:dataSet/a:component) != ''">
405 <xsl:text>:</xsl:text>
406 <xsl:value-of select="normalize-space(a:dataSet/a:component)"/>
407 </xsl:if>
408 <xsl:if test="normalize-space(a:dataSet/a:component) != ''">
409 <xsl:text>:</xsl:text>
410 <xsl:value-of select="normalize-space(a:dataSet/a:instance)"/>
411 </xsl:if>
412
413 </titl>
414 <IDNo agency="producer">
415 <xsl:value-of select="normalize-space(a:dataSet/a:shortName)"/>
416 <xsl:text>/</xsl:text>
417 <xsl:value-of select="normalize-space(a:dataSet/a:subsurveyName)"/>
418 <xsl:text>/</xsl:text>
419 <xsl:value-of select="normalize-space(a:dataSet/a:component)"/>
420 <xsl:text>/</xsl:text>
421 <xsl:value-of select="normalize-space(a:dataSet/a:instance)"/>
422 </IDNo>
423 </titlStmt>
424 </xsl:template>
425
426 <xsl:template name="full-path">
427 <xsl:for-each select="ancestor-or-self::*">
428 <xsl:variable name="id" select="generate-id(.)"/>
429 <xsl:variable name="name" select="name()"/>
430 <xsl:value-of select="concat('/',name())"/>
431 <xsl:for-each select="../*[name()=$name]">
432 <xsl:if test="generate-id(.)=$id">
433 <xsl:text>[</xsl:text>
434 <xsl:value-of select="position()"/>
435 <xsl:text>]</xsl:text>
436 </xsl:if>
437 </xsl:for-each>
438 </xsl:for-each>
439 <xsl:if test="not(self::*)">
440 <xsl:choose>
441 <xsl:when test="self::text()">
442 <xsl:text>/text()</xsl:text>
443 <xsl:text>[</xsl:text>
444 <xsl:value-of select="position()"/>
445 <xsl:text>]</xsl:text>
446 </xsl:when>
447 <xsl:when test="self::comment()">
448 <xsl:text>/comment()</xsl:text>
449 <xsl:text>[</xsl:text>
450 <xsl:value-of select="position()"/>
451 <xsl:text>]</xsl:text>
452 </xsl:when>
453 <xsl:when test="self::processing-instruction()">
454 <xsl:text>/processing-instruction()</xsl:text>
455 <xsl:text>[</xsl:text>
456 <xsl:value-of select="position()"/>
457 <xsl:text>]</xsl:text>
458 </xsl:when>
459 <xsl:otherwise>
460 <xsl:value-of select="concat('/@',name())"/>
461 </xsl:otherwise>
462 </xsl:choose>
463 </xsl:if>
464 </xsl:template>
465
466 </xsl:stylesheet>