bibframe_ruby 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -2
  3. data/docs/superpowers/plans/2026-09-09-marc-conversion.md +537 -0
  4. data/docs/superpowers/specs/2026-09-09-marc-conversion-design.md +110 -0
  5. data/lib/bibframe_ruby/marc_converter.rb +67 -0
  6. data/lib/bibframe_ruby/parser.rb +4 -2
  7. data/lib/bibframe_ruby/version.rb +1 -1
  8. data/lib/bibframe_ruby.rb +7 -0
  9. data/vendor/marc2bibframe2/xsl/ConvSpec-001-007.xsl +2276 -0
  10. data/vendor/marc2bibframe2/xsl/ConvSpec-006,008.xsl +1295 -0
  11. data/vendor/marc2bibframe2/xsl/ConvSpec-010-048.xsl +1712 -0
  12. data/vendor/marc2bibframe2/xsl/ConvSpec-050-088.xsl +713 -0
  13. data/vendor/marc2bibframe2/xsl/ConvSpec-1XX,7XX,8XX-names.xsl +1141 -0
  14. data/vendor/marc2bibframe2/xsl/ConvSpec-200-247not240-Titles.xsl +771 -0
  15. data/vendor/marc2bibframe2/xsl/ConvSpec-240andX30-UnifTitle.xsl +535 -0
  16. data/vendor/marc2bibframe2/xsl/ConvSpec-250-270.xsl +283 -0
  17. data/vendor/marc2bibframe2/xsl/ConvSpec-3XX.xsl +2245 -0
  18. data/vendor/marc2bibframe2/xsl/ConvSpec-460-468-SeriesTreat.xsl +135 -0
  19. data/vendor/marc2bibframe2/xsl/ConvSpec-490-510-Links.xsl +145 -0
  20. data/vendor/marc2bibframe2/xsl/ConvSpec-5XX.xsl +1448 -0
  21. data/vendor/marc2bibframe2/xsl/ConvSpec-600-662.xsl +1417 -0
  22. data/vendor/marc2bibframe2/xsl/ConvSpec-720+740to755.xsl +333 -0
  23. data/vendor/marc2bibframe2/xsl/ConvSpec-758.xsl +102 -0
  24. data/vendor/marc2bibframe2/xsl/ConvSpec-760-788-Links.xsl +771 -0
  25. data/vendor/marc2bibframe2/xsl/ConvSpec-841-887.xsl +328 -0
  26. data/vendor/marc2bibframe2/xsl/ConvSpec-880.xsl +119 -0
  27. data/vendor/marc2bibframe2/xsl/ConvSpec-ControlSubfields.xsl +495 -0
  28. data/vendor/marc2bibframe2/xsl/ConvSpec-LDR.xsl +183 -0
  29. data/vendor/marc2bibframe2/xsl/ConvSpec-Preprocess0-Splitting.xsl +765 -0
  30. data/vendor/marc2bibframe2/xsl/ConvSpec-Process6-Series.xsl +627 -0
  31. data/vendor/marc2bibframe2/xsl/ConvSpec-Process8-ProvAct.xsl +1021 -0
  32. data/vendor/marc2bibframe2/xsl/conf/abbreviations.xml +13 -0
  33. data/vendor/marc2bibframe2/xsl/conf/code-to-script.xml +399 -0
  34. data/vendor/marc2bibframe2/xsl/conf/codeMaps.xml +723 -0
  35. data/vendor/marc2bibframe2/xsl/conf/exclusions.xml +4 -0
  36. data/vendor/marc2bibframe2/xsl/conf/iso6392-to-1.xml +615 -0
  37. data/vendor/marc2bibframe2/xsl/conf/languageCrosswalk.xml +1503 -0
  38. data/vendor/marc2bibframe2/xsl/conf/map880.xml +175 -0
  39. data/vendor/marc2bibframe2/xsl/conf/scriptCrosswalk.xml +210 -0
  40. data/vendor/marc2bibframe2/xsl/conf/subjectThesaurus.xml +29 -0
  41. data/vendor/marc2bibframe2/xsl/marc2bibframe2.xsl +610 -0
  42. data/vendor/marc2bibframe2/xsl/naco-normalize.xsl +205 -0
  43. data/vendor/marc2bibframe2/xsl/utils.xsl +963 -0
  44. data/vendor/marc2bibframe2/xsl/variables.xsl +108 -0
  45. metadata +68 -1
@@ -0,0 +1,1021 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet version="1.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
3
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:marc="http://www.loc.gov/MARC21/slim"
4
+ xmlns:bf="http://id.loc.gov/ontologies/bibframe/"
5
+ xmlns:bflc="http://id.loc.gov/ontologies/bflc/" xmlns:madsrdf="http://www.loc.gov/mads/rdf/v1#"
6
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"
7
+ exclude-result-prefixes="xsl marc">
8
+
9
+ <!-- Conversion specs for Process8 -->
10
+
11
+ <!--<xsl:template
12
+ match="
13
+ marc:datafield[@tag = '260' or (@tag = '880' and substring(marc:subfield[@code = '6'], 1, 3) = '260')] |
14
+ marc:datafield[@tag = '262'] |
15
+ marc:datafield[@tag = '264' or (@tag = '880' and substring(marc:subfield[@code = '6'], 1, 3) = '264')]"
16
+ mode="instance">-->
17
+ <!-- Why did the above also select 880s? Is it possible to have 880s but no 26X. If so, would that even have output anything? -->
18
+ <xsl:template name="process8">
19
+
20
+ <xsl:variable name="v26xFields" select="../marc:datafield[@tag = '260']|../marc:datafield[@tag = '261']|../marc:datafield[@tag = '262']|../marc:datafield[@tag = '264']" />
21
+ <xsl:variable name="v880Fields" select="../marc:datafield[@tag = '880' and substring(marc:subfield[@code = '6'], 1, 2) = '26' and substring(marc:subfield[@code = '6'], 1, 3) != '263']" />
22
+
23
+ <!-- This is need to assist with handling ind1 properly. i is integrating; s is serial -->
24
+ <xsl:variable name="vleader07TypeValue" select="substring(../marc:leader,8,1)" />
25
+ <xsl:variable name="v26xFieldsCount" select="count($v26xFields)" />
26
+
27
+ <!--
28
+ This variable looks like (it may also have a status property or note):
29
+ <paGroup>
30
+ <type>Publication</type>
31
+ <bf:date rdf:datatype="http://id.loc.gov/datatypes/edtf">1987</bf:date>
32
+ <bf:place rdf:resource="http://id.loc.gov/vocabulary/countries/ja"/>
33
+ </paGroup>
34
+ ...
35
+ -->
36
+ <xsl:variable name="cf008data-prenodeset">
37
+ <xsl:apply-templates select="../marc:controlfield[@tag = '008']" mode="process8"/>
38
+ </xsl:variable>
39
+ <xsl:variable name="cf008data" select="exsl:node-set($cf008data-prenodeset)"/>
40
+ <!--<xsl:copy-of select="$cf008data" />-->
41
+
42
+ <!--
43
+ This variable looks like:
44
+ <marc:sfGroup xmlns:marc="http://www.loc.gov/MARC21/slim" tag="264">
45
+ <marc:df tag="880" ind1=" " ind2=" ">
46
+ <marc:sf code="6">260-02/$1</marc:sf>
47
+ <marc:sf code="a">[S.l. :</marc:sf>
48
+ <marc:sf code="b">s.n.,</marc:sf>
49
+ <marc:sf code="c">昭和 62 i.e. 1987]</marc:sf>
50
+ </marc:df>
51
+ <marc:df tag="264" ind1=" " ind2="1">
52
+ <marc:sf code="a" gpos="2" pos="2">[S.l. :</marc:sf>
53
+ <marc:sf code="b" gpos="2" pos="3">s.n.,</marc:sf>
54
+ <marc:sf code="c" gpos="2" pos="4">Shōwa 62 i.e. 1987]</marc:sf>
55
+ </marc:df>
56
+ </marc:sfGroup>
57
+ ...
58
+ -->
59
+ <xsl:variable name="sfblocks-prenodeset">
60
+ <xsl:for-each select="$v26xFields">
61
+ <xsl:variable name="vTag">
62
+ <xsl:choose>
63
+ <xsl:when test="@tag = '880'">
64
+ <xsl:value-of select="substring(marc:subfield[@code = '6'], 1, 3)"/>
65
+ </xsl:when>
66
+ <xsl:otherwise>
67
+ <xsl:value-of select="@tag"/>
68
+ </xsl:otherwise>
69
+ </xsl:choose>
70
+ </xsl:variable>
71
+
72
+ <xsl:variable name="v880Occurrence">
73
+ <xsl:value-of select="substring(substring-after(marc:subfield[@code = '6'], '-'), 1, 2)"/>
74
+ </xsl:variable>
75
+ <xsl:variable name="v880Ref">
76
+ <xsl:value-of select="concat($vTag, '-', $v880Occurrence)"/>
77
+ </xsl:variable>
78
+
79
+ <xsl:call-template name="blockize26x">
80
+ <xsl:with-param name="df" select="self::node()"/>
81
+ <xsl:with-param name="v880Ref" select="$v880Ref"/>
82
+ </xsl:call-template>
83
+ </xsl:for-each>
84
+
85
+ <xsl:for-each select="$v880Fields">
86
+ <xsl:variable name="vTag">
87
+ <xsl:value-of select="substring(marc:subfield[@code = '6'], 1, 3)"/>
88
+ </xsl:variable>
89
+
90
+ <xsl:variable name="v880Occurrence">
91
+ <xsl:value-of select="substring(substring-after(marc:subfield[@code = '6'], '-'), 1, 2)"/>
92
+ </xsl:variable>
93
+ <xsl:variable name="v880Ref">
94
+ <xsl:value-of select="concat('880-', $v880Occurrence)"/>
95
+ </xsl:variable>
96
+
97
+ <!-- Is this 880 related to a 26X field in this record? -->
98
+ <xsl:variable name="relatedField" select="../marc:datafield[@tag = $vTag and contains(marc:subfield[@code = '6'], $v880Ref)]" />
99
+
100
+ <!-- commented out on 30 Aug 2024. Did doing this break something? -->
101
+ <!-- <xsl:copy-of select="$relatedField"/> -->
102
+
103
+ <!-- If no related field was found, then we have an unpaied 880. We need to output it. -->
104
+ <xsl:if test="count($relatedField/marc:*) = 0">
105
+ <xsl:variable name="dfFrom880-prenodeset">
106
+ <marc:datafield>
107
+ <xsl:attribute name="tag"><xsl:value-of select="$vTag"/></xsl:attribute>
108
+ <xsl:copy-of select="@ind1" />
109
+ <xsl:copy-of select="@ind2" />
110
+ <xsl:for-each select="marc:subfield[@code != '6']">
111
+ <marc:subfield>
112
+ <xsl:attribute name="code"><xsl:value-of select="@code"/></xsl:attribute>
113
+ <xsl:value-of select="."/>
114
+ </marc:subfield>
115
+ </xsl:for-each>
116
+ <!-- <xsl:copy-of select="marc:subfield[@code != '6']"/> -->
117
+ </marc:datafield>
118
+ </xsl:variable>
119
+ <xsl:variable name="dfFrom880" select="exsl:node-set($dfFrom880-prenodeset)" />
120
+
121
+ <xsl:call-template name="blockize26x">
122
+ <xsl:with-param name="df" select="$dfFrom880/marc:datafield"/>
123
+ <xsl:with-param name="v880Ref" select="'bananas'"/>
124
+ </xsl:call-template>
125
+ </xsl:if>
126
+ </xsl:for-each>
127
+ </xsl:variable>
128
+ <xsl:variable name="sfblocks" select="exsl:node-set($sfblocks-prenodeset)"/>
129
+ <!-- <xsl:message><xsl:copy-of select="$sfblocks"/></xsl:message> -->
130
+
131
+ <xsl:for-each select="$sfblocks/marc:sfGroup">
132
+ <xsl:variable name="sfgTag" select="@tag"/>
133
+ <xsl:variable name="df" select="marc:df[@tag = $sfgTag]"/>
134
+ <xsl:variable name="ind2val" select="$df/@ind2"/>
135
+ <xsl:variable name="vProvisionActivity">
136
+ <xsl:choose>
137
+ <xsl:when test="$ind2val = '0'">Production</xsl:when>
138
+ <xsl:when test="$ind2val = '1'">Publication</xsl:when>
139
+ <xsl:when test="$ind2val = '2'">Distribution</xsl:when>
140
+ <xsl:when test="$ind2val = '3'">Manufacture</xsl:when>
141
+ </xsl:choose>
142
+ </xsl:variable>
143
+ <xsl:variable name="vcf008-prenodeset">
144
+ <xsl:if test=" $vProvisionActivity != ''
145
+ and
146
+ count(following-sibling::marc:sfGroup/marc:df[@tag = $sfgTag and @ind2 = $ind2val]) = 0
147
+ ">
148
+ <xsl:copy-of select="$cf008data/paGroup[type = $vProvisionActivity]/bf:*" />
149
+ </xsl:if>
150
+ </xsl:variable>
151
+ <xsl:variable name="vcf008" select="exsl:node-set($vcf008-prenodeset)"/>
152
+ <xsl:variable name="vStatement">
153
+ <xsl:apply-templates select="$df/marc:sf[@code = 'a' or @code = 'b' or @code = 'c']"
154
+ mode="concat-nodes-delimited"/>
155
+ </xsl:variable>
156
+ <xsl:variable name="has880">
157
+ <xsl:choose>
158
+ <xsl:when test="marc:df[@tag = '880']">
159
+ <xsl:value-of select="true()"/>
160
+ </xsl:when>
161
+ <xsl:otherwise>
162
+ <xsl:value-of select="false()"/>
163
+ </xsl:otherwise>
164
+ </xsl:choose>
165
+ </xsl:variable>
166
+ <xsl:variable name="v880" select="marc:df[@tag = '880']"/>
167
+
168
+ <xsl:variable name="vXmlLang"><xsl:value-of select="$df/@xmllang" /></xsl:variable>
169
+ <xsl:variable name="vLinkedXmlLang"><xsl:value-of select="marc:df[@tag = '880']/@xmllang" /></xsl:variable>
170
+ <xsl:variable name="vLinkedStatement">
171
+ <xsl:if test="$has880">
172
+ <xsl:apply-templates
173
+ select="$v880/marc:sf[@code = 'a' or @code = 'b' or @code = 'c']"
174
+ mode="concat-nodes-delimited"/>
175
+ </xsl:if>
176
+ </xsl:variable>
177
+ <xsl:choose>
178
+ <xsl:when test="$serialization = 'rdfxml'">
179
+ <xsl:choose>
180
+ <xsl:when test="$sfgTag = '264' and $df/@ind2 = '4'">
181
+ <xsl:choose>
182
+ <xsl:when test="$cf008data/paGroup[type = 'Copyright']">
183
+ <xsl:copy-of
184
+ select="$cf008data/paGroup[type = 'Copyright']/bf:*"/>
185
+ </xsl:when>
186
+ <xsl:otherwise>
187
+ <bf:copyrightDate>
188
+ <xsl:if test="$vXmlLang != ''">
189
+ <xsl:attribute name="xml:lang">
190
+ <xsl:value-of select="$vXmlLang"/>
191
+ </xsl:attribute>
192
+ </xsl:if>
193
+ <xsl:call-template name="tChopPunct">
194
+ <xsl:with-param name="pString" select="translate($vStatement, '©℗', '')"/>
195
+ </xsl:call-template>
196
+ </bf:copyrightDate>
197
+ <xsl:if test="$vLinkedStatement != ''">
198
+ <bf:copyrightDate>
199
+ <xsl:if test="$vLinkedXmlLang != ''">
200
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vLinkedXmlLang"/></xsl:attribute>
201
+ </xsl:if>
202
+ <xsl:call-template name="tChopPunct">
203
+ <xsl:with-param name="pString"
204
+ select="translate($vLinkedStatement, '©℗', '')"/>
205
+ </xsl:call-template>
206
+ </bf:copyrightDate>
207
+ </xsl:if>
208
+ </xsl:otherwise>
209
+
210
+ </xsl:choose>
211
+ </xsl:when>
212
+ <xsl:otherwise>
213
+ <xsl:variable name="thePA">
214
+ <bf:provisionActivity>
215
+ <bf:ProvisionActivity>
216
+ <xsl:if test="$vProvisionActivity != ''">
217
+ <rdf:type>
218
+ <xsl:attribute name="rdf:resource">
219
+ <xsl:value-of
220
+ select="concat($bf, $vProvisionActivity)"/>
221
+ </xsl:attribute>
222
+ </rdf:type>
223
+ <xsl:copy-of select="$vcf008"/>
224
+ </xsl:if>
225
+ <!--
226
+ 8.6.3) If rdf:type=Serial or rdf:type=Integrating and more than one 26X field exists:
227
+ For 26X Ind1=# ; add bf:status http://id.loc.gof/vocabulary/mstatus/earliest ; and rdfs:label “earliest”
228
+ For 26X Ind1=3 ; add bf:status http://id.loc.gof/vocabulary/mstatus/current ; and rdfs:label “current”
229
+ -->
230
+ <xsl:if test="($vleader07TypeValue='s' or $vleader07TypeValue='i') and $v26xFieldsCount > 1 and $vProvisionActivity='Publication'">
231
+ <xsl:if test="not($vcf008/bf:status) and $df/@ind1 = ' '">
232
+ <bf:status>
233
+ <bf:Status rdf:about="http://id.loc.gov/vocabulary/mstatus/earliest">
234
+ <rdfs:label>earliest</rdfs:label>
235
+ </bf:Status>
236
+ </bf:status>
237
+ </xsl:if>
238
+ <xsl:if test="not($vcf008/bf:status) and $df/@ind1 = '3'">
239
+ <bf:status>
240
+ <bf:Status rdf:about="http://id.loc.gov/vocabulary/mstatus/current">
241
+ <rdfs:label>current</rdfs:label>
242
+ </bf:Status>
243
+ </bf:status>
244
+ </xsl:if>
245
+ </xsl:if>
246
+ <!-- 8.6.2) If rdf:type=Integrating and just one 26X field exists, add bf:status -->
247
+ <xsl:if test="not($vcf008/bf:status) and $vleader07TypeValue='i' and $v26xFieldsCount = 1 and $vProvisionActivity='Publication'">
248
+ <bf:status>
249
+ <bf:Status rdf:about="http://id.loc.gov/vocabulary/mstatus/current">
250
+ <rdfs:label>current</rdfs:label>
251
+ </bf:Status>
252
+ </bf:status>
253
+ </xsl:if>
254
+
255
+ <xsl:choose>
256
+ <xsl:when test="$df/marc:sf[@code = '3']">
257
+ <xsl:apply-templates
258
+ select="$df/marc:sf[@code = '3'][1]"
259
+ mode="subfield3">
260
+ <xsl:with-param name="serialization" select="$serialization"/>
261
+ </xsl:apply-templates>
262
+ </xsl:when>
263
+ <xsl:when test="marc:df[@tag = '880']/marc:sf[@code = '3']">
264
+ <xsl:apply-templates
265
+ select="marc:df[@tag = '880']/marc:sf[@code = '3'][1]"
266
+ mode="subfield3">
267
+ <xsl:with-param name="serialization" select="$serialization"/>
268
+ </xsl:apply-templates>
269
+ </xsl:when>
270
+ </xsl:choose>
271
+ <xsl:for-each select="$df/marc:sf[@code = 'a']">
272
+ <xsl:variable name="sfPos" select="@pos"/>
273
+ <xsl:variable name="vLabel">
274
+ <xsl:call-template name="tChopPunct">
275
+ <xsl:with-param name="pString" select="."/>
276
+ </xsl:call-template>
277
+ </xsl:variable>
278
+ <xsl:variable name="vLinkedLabel">
279
+ <xsl:if test="$has880">
280
+ <xsl:call-template name="tChopPunct">
281
+ <xsl:with-param name="pString"
282
+ select="$df/../marc:df[@tag = '880']/marc:sf[position() = $sfPos]"
283
+ />
284
+ </xsl:call-template>
285
+ </xsl:if>
286
+ </xsl:variable>
287
+ <bflc:simplePlace>
288
+ <xsl:apply-templates select="ancestor::marc:df" mode="xmllang-attribute">
289
+ <xsl:with-param name="pSFCode" select="'a'" />
290
+ <xsl:with-param name="pXMLlang" select="$vXmlLang" />
291
+ </xsl:apply-templates>
292
+ <xsl:value-of select="$vLabel"/>
293
+ </bflc:simplePlace>
294
+ <xsl:if test="$vLinkedLabel != ''">
295
+ <bflc:simplePlace>
296
+ <xsl:if test="$vLinkedXmlLang != ''">
297
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vLinkedXmlLang"/></xsl:attribute>
298
+ </xsl:if>
299
+ <xsl:value-of select="$vLinkedLabel"/>
300
+ </bflc:simplePlace>
301
+ </xsl:if>
302
+ </xsl:for-each>
303
+ <xsl:for-each select="$df/marc:sf[@code = 'b']">
304
+ <xsl:variable name="sfPos" select="@pos"/>
305
+ <xsl:variable name="vLabel">
306
+ <!-- detect if there are unmatched brackets in preceding or following subfield -->
307
+ <xsl:variable name="vAddBrackets"
308
+ select="
309
+ (
310
+ not(contains(., '[')) and
311
+ not(contains(., ']')) and
312
+ (
313
+ (
314
+ contains(preceding-sibling::marc:sf[@code = 'a'][1], '[') and
315
+ not(contains(preceding-sibling::marc:sf[@code = 'a'][1], ']'))
316
+ ) or
317
+ (
318
+ contains(following-sibling::marc:sf[@code = 'c'][1], ']') and
319
+ not(contains(following-sibling::marc:sf[@code = 'c'][1], '['))
320
+ )
321
+ )
322
+ ) = true()"/>
323
+ <xsl:call-template name="tChopPunct">
324
+ <xsl:with-param name="pString" select="."/>
325
+ <xsl:with-param name="pAddBrackets"
326
+ select="$vAddBrackets"/>
327
+ </xsl:call-template>
328
+ </xsl:variable>
329
+ <xsl:variable name="vLinkedLabel">
330
+ <xsl:if test="$has880">
331
+ <!-- detect if there are unmatched brackets in preceding or following subfield -->
332
+ <xsl:variable name="vAddBrackets"
333
+ select="
334
+ (
335
+ not(contains($v880/marc:sf[@code = 'b'][position()], '[')) and
336
+ not(contains($v880/marc:sf[@code = 'b'][position()], ']')) and
337
+ (
338
+ (
339
+ contains($v880/marc:sf[@code = 'b'][position()]/preceding-sibling::marc:sf[@code = 'a'][1], '[') and
340
+ not(contains($v880/marc:sf[@code = 'b'][position()]/preceding-sibling::marc:sf[@code = 'a'][1], ']'))
341
+ ) or
342
+ (
343
+ contains($v880/marc:sf[@code = 'b'][position()]/following-sibling::marc:sf[@code = 'c'][1], ']') and
344
+ not(contains($v880/marc:sf[@code = 'b'][position()]/following-sibling::marc:sf[@code = 'c'][1], '['))
345
+ )
346
+ )
347
+ ) = true()"/>
348
+
349
+ <xsl:call-template name="tChopPunct">
350
+ <xsl:with-param name="pString"
351
+ select="$df/../marc:df[@tag = '880']/marc:sf[position() = $sfPos]"/>
352
+ <xsl:with-param name="pAddBrackets"
353
+ select="$vAddBrackets"/>
354
+ </xsl:call-template>
355
+ </xsl:if>
356
+ </xsl:variable>
357
+ <bflc:simpleAgent>
358
+ <xsl:apply-templates select="ancestor::marc:df" mode="xmllang-attribute">
359
+ <xsl:with-param name="pSFCode" select="'b'" />
360
+ <xsl:with-param name="pXMLlang" select="$vXmlLang" />
361
+ </xsl:apply-templates>
362
+ <xsl:value-of select="$vLabel"/>
363
+ </bflc:simpleAgent>
364
+ <xsl:if test="$vLinkedLabel != ''">
365
+ <bflc:simpleAgent>
366
+ <xsl:if test="$vLinkedXmlLang != ''">
367
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vLinkedXmlLang"/></xsl:attribute>
368
+ </xsl:if>
369
+ <xsl:value-of select="$vLinkedLabel"/>
370
+ </bflc:simpleAgent>
371
+ </xsl:if>
372
+ </xsl:for-each>
373
+ <xsl:for-each select="$df/marc:sf[@code = 'c']">
374
+ <xsl:variable name="sfPos" select="@pos"/>
375
+ <xsl:variable name="vLabel">
376
+ <xsl:call-template name="tChopPunct">
377
+ <xsl:with-param name="pString" select="."/>
378
+ </xsl:call-template>
379
+ </xsl:variable>
380
+ <xsl:variable name="vLinkedLabel">
381
+ <xsl:if test="$has880">
382
+ <xsl:call-template name="tChopPunct">
383
+ <xsl:with-param name="pString"
384
+ select="$df/../marc:df[@tag = '880']/marc:sf[position() = $sfPos]"
385
+ />
386
+ </xsl:call-template>
387
+ </xsl:if>
388
+ </xsl:variable>
389
+ <bflc:simpleDate>
390
+ <xsl:apply-templates select="ancestor::marc:df" mode="xmllang-attribute">
391
+ <xsl:with-param name="pSFCode" select="'c'" />
392
+ <xsl:with-param name="pXMLlang" select="$vXmlLang" />
393
+ </xsl:apply-templates>
394
+ <xsl:value-of select="$vLabel"/>
395
+ </bflc:simpleDate>
396
+ <xsl:if test="$vLinkedLabel != ''">
397
+ <bflc:simpleDate>
398
+ <xsl:if test="$vLinkedXmlLang != ''">
399
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vLinkedXmlLang"/></xsl:attribute>
400
+ </xsl:if>
401
+ <xsl:value-of select="$vLinkedLabel"/>
402
+ </bflc:simpleDate>
403
+ </xsl:if>
404
+ </xsl:for-each>
405
+ </bf:ProvisionActivity>
406
+ </bf:provisionActivity>
407
+ </xsl:variable>
408
+ <xsl:copy-of select="$thePA" />
409
+ <xsl:variable name="thePAasNodeSet" select="exsl:node-set($thePA)" />
410
+ <xsl:if test="$thePAasNodeSet//bflc:*[not(@xml:lang)]">
411
+ <xsl:element name="{concat('bf:', translate($vProvisionActivity, $upper, $lower), 'Statement')}">
412
+ <xsl:apply-templates select="exsl:node-set($thePA)//bflc:simplePlace[not(@xml:lang)]" mode="concat-nodes-delimited">
413
+ <xsl:with-param name="pDelimiter" select="';'"/>
414
+ </xsl:apply-templates>
415
+ <xsl:if test="exsl:node-set($thePA)//bflc:simplePlace and (exsl:node-set($thePA)//bflc:simpleAgent or exsl:node-set($thePA)//bflc:simpleDate)">: </xsl:if>
416
+ <xsl:apply-templates select="exsl:node-set($thePA)//bflc:simpleAgent[not(@xml:lang)]" mode="concat-nodes-delimited">
417
+ <xsl:with-param name="pDelimiter" select="','"/>
418
+ </xsl:apply-templates>
419
+ <xsl:if test="exsl:node-set($thePA)//bflc:simpleAgent and exsl:node-set($thePA)//bflc:simpleDate">, </xsl:if>
420
+ <xsl:apply-templates select="exsl:node-set($thePA)//bflc:simpleDate[not(@xml:lang)]" mode="concat-nodes-delimited">
421
+ <xsl:with-param name="pDelimiter" select="','"/>
422
+ </xsl:apply-templates>
423
+ </xsl:element>
424
+ </xsl:if>
425
+ <xsl:if test="$thePAasNodeSet//bflc:*[@xml:lang]">
426
+ <xsl:element name="{concat('bf:', translate($vProvisionActivity, $upper, $lower), 'Statement')}">
427
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$thePAasNodeSet//bflc:*[@xml:lang]/@xml:lang"/></xsl:attribute>
428
+ <xsl:apply-templates select="exsl:node-set($thePA)//bflc:simplePlace[@xml:lang]" mode="concat-nodes-delimited">
429
+ <xsl:with-param name="pDelimiter" select="';'"/>
430
+ </xsl:apply-templates>
431
+ <xsl:if test="exsl:node-set($thePA)//bflc:simplePlace and (exsl:node-set($thePA)//bflc:simpleAgent or exsl:node-set($thePA)//bflc:simpleDate)">: </xsl:if>
432
+ <xsl:apply-templates select="exsl:node-set($thePA)//bflc:simpleAgent[@xml:lang]" mode="concat-nodes-delimited">
433
+ <xsl:with-param name="pDelimiter" select="','"/>
434
+ </xsl:apply-templates>
435
+ <xsl:if test="exsl:node-set($thePA)//bflc:simpleAgent and exsl:node-set($thePA)//bflc:simpleDate">, </xsl:if>
436
+ <xsl:apply-templates select="exsl:node-set($thePA)//bflc:simpleDate[@xml:lang]" mode="concat-nodes-delimited">
437
+ <xsl:with-param name="pDelimiter" select="','"/>
438
+ </xsl:apply-templates>
439
+ </xsl:element>
440
+ </xsl:if>
441
+
442
+ </xsl:otherwise>
443
+ </xsl:choose>
444
+ </xsl:when>
445
+ </xsl:choose>
446
+ </xsl:for-each>
447
+
448
+ <!-- Need to check for any paGroups from the 008 that did not match a group from the 26x. -->
449
+ <xsl:for-each select="$cf008data/paGroup">
450
+ <xsl:variable name="vProvisionActivity"><xsl:value-of select="type"/></xsl:variable>
451
+ <xsl:variable name="ind2val">
452
+ <xsl:choose>
453
+ <xsl:when test="$vProvisionActivity = 'Production'">0</xsl:when>
454
+ <xsl:when test="$vProvisionActivity = 'Publication'">1</xsl:when>
455
+ <xsl:when test="$vProvisionActivity = 'Distribution'">2</xsl:when>
456
+ <xsl:when test="$vProvisionActivity = 'Manufacture'">3</xsl:when>
457
+ </xsl:choose>
458
+ </xsl:variable>
459
+ <xsl:if test="$vProvisionActivity != 'Copyright' and not($sfblocks/marc:sfGroup/marc:df[@tag = '264' and @ind2 = $ind2val])">
460
+ <bf:provisionActivity>
461
+ <bf:ProvisionActivity>
462
+ <rdf:type>
463
+ <xsl:attribute name="rdf:resource">
464
+ <xsl:value-of
465
+ select="concat($bf, $vProvisionActivity)"/>
466
+ </xsl:attribute>
467
+ </rdf:type>
468
+ <xsl:copy-of select="bf:*"/>
469
+ </bf:ProvisionActivity>
470
+ </bf:provisionActivity>
471
+ </xsl:if>
472
+ <xsl:if test="$vProvisionActivity = 'Copyright' and not($sfblocks/marc:sfGroup/marc:df[@tag = '264' and @ind2 = '4'])">
473
+ <xsl:copy-of select="bf:*"/>
474
+ </xsl:if>
475
+ </xsl:for-each>
476
+
477
+ </xsl:template>
478
+
479
+
480
+ <xsl:template name="blockize26x">
481
+ <xsl:param name="df"/>
482
+ <xsl:param name="v880Ref"/>
483
+
484
+ <!-- Parse the subfields in this datafield. -->
485
+ <xsl:variable name="parsedSfs-prenodeset">
486
+ <xsl:call-template name="parse26x">
487
+ <xsl:with-param name="df" select="$df"/>
488
+ <xsl:with-param name="gpos" select="1"/>
489
+ <xsl:with-param name="pos" select="1"/>
490
+ </xsl:call-template>
491
+ </xsl:variable>
492
+ <xsl:variable name="parsedSfs" select="exsl:node-set($parsedSfs-prenodeset)"/>
493
+ <!-- <xsl:message><xsl:copy-of select="$parsedSfs"/></xsl:message> -->
494
+
495
+ <!-- Find the group numbers. -->
496
+ <xsl:variable name="groups-prenodeset">
497
+ <xsl:for-each select="$parsedSfs/marc:sf">
498
+ <xsl:variable name="g" select="@gpos"/>
499
+ <xsl:choose>
500
+ <xsl:when test="count(preceding::marc:sf) = 0">
501
+ <group>
502
+ <xsl:value-of select="$g"/>
503
+ </group>
504
+ </xsl:when>
505
+ <xsl:when test="preceding::marc:sf[1][@gpos != $g]">
506
+ <group>
507
+ <xsl:value-of select="$g"/>
508
+ </group>
509
+ </xsl:when>
510
+ </xsl:choose>
511
+ </xsl:for-each>
512
+ </xsl:variable>
513
+ <xsl:variable name="groups" select="exsl:node-set($groups-prenodeset)" />
514
+
515
+ <!-- If this datafield has a corresponding 880, extract it. -->
516
+ <xsl:variable name="df880">
517
+ <xsl:if test="$df/marc:subfield[@code = '6']">
518
+ <xsl:variable name="related880-prenodeset">
519
+ <xsl:copy-of select="$df/../marc:datafield[@tag = '880' and contains(marc:subfield[@code = '6'], $v880Ref)]"/>
520
+ </xsl:variable>
521
+ <xsl:variable name="related880" select="exsl:node-set($related880-prenodeset)" />
522
+
523
+ <marc:df>
524
+ <xsl:copy-of select="$related880/marc:datafield/@*"/>
525
+ <xsl:attribute name="xmllang">
526
+ <xsl:apply-templates select="$df/../marc:datafield[@tag = '880' and contains(marc:subfield[@code = '6'], $v880Ref)]" mode="xmllang"/>
527
+ </xsl:attribute>
528
+ <xsl:for-each select="$related880/marc:datafield/marc:subfield">
529
+ <marc:sf>
530
+ <xsl:copy-of select="@*"/>
531
+ <xsl:copy-of select="text()"/>
532
+ </marc:sf>
533
+ </xsl:for-each>
534
+ </marc:df>
535
+ </xsl:if>
536
+ </xsl:variable>
537
+
538
+ <!-- Take parsed subfields and related 880, if there is one, and generate groups. -->
539
+ <xsl:for-each select="$groups/group">
540
+ <xsl:variable name="g" select="."/>
541
+ <marc:sfGroup tag="264">
542
+ <xsl:copy-of select="$df880"/>
543
+ <marc:df tag="264">
544
+ <xsl:copy-of select="$df/@ind1"/>
545
+ <xsl:attribute name="ind2">
546
+ <xsl:choose>
547
+ <xsl:when
548
+ test="$parsedSfs/marc:sf[@gpos = $g][1][@type = 'Production']"
549
+ >0</xsl:when>
550
+ <xsl:when
551
+ test="$parsedSfs/marc:sf[@gpos = $g][1][@type = 'Publication']"
552
+ >1</xsl:when>
553
+ <xsl:when
554
+ test="$parsedSfs/marc:sf[@gpos = $g][1][@type = 'Distribution']"
555
+ >2</xsl:when>
556
+ <xsl:when
557
+ test="$parsedSfs/marc:sf[@gpos = $g][1][@type = 'Manufacture']"
558
+ >3</xsl:when>
559
+ <xsl:when test="$df/@tag = '264'">
560
+ <xsl:value-of select="$df/@ind2"/>
561
+ </xsl:when>
562
+ <xsl:otherwise>1</xsl:otherwise>
563
+ </xsl:choose>
564
+ </xsl:attribute>
565
+ <xsl:attribute name="xmllang">
566
+ <xsl:apply-templates select="$df" mode="xmllang"/>
567
+ </xsl:attribute>
568
+ <xsl:for-each select="$df/marc:subfield[@code = '3']">
569
+ <marc:sf>
570
+ <xsl:copy-of select="@*"/>
571
+ <xsl:copy-of select="text()"/>
572
+ </marc:sf>
573
+ </xsl:for-each>
574
+ <xsl:for-each select="$parsedSfs/marc:sf[@gpos = $g]">
575
+ <xsl:copy-of select="."/>
576
+ </xsl:for-each>
577
+ </marc:df>
578
+ </marc:sfGroup>
579
+ </xsl:for-each>
580
+
581
+ </xsl:template>
582
+
583
+ <!--
584
+ Recursively parse a 26x, subfield by subfield.
585
+ This makes all 26x a 264.
586
+ This template determines which group a subfield goes in based on the Spec's process instructions.
587
+ It adds a group number to each, which is group-ized later.
588
+ -->
589
+ <xsl:template name="parse26x">
590
+ <xsl:param name="df"/>
591
+ <xsl:param name="pos"/>
592
+ <xsl:param name="gpos"/>
593
+
594
+ <xsl:variable name="sf" select="$df/marc:subfield[$pos]"/>
595
+
596
+ <xsl:choose>
597
+ <xsl:when test="$sf/@code = '3' or $sf/@code = '6' or $sf/@code = '7'">
598
+ <marc:sf>
599
+ <xsl:copy-of select="$sf/@*"/>
600
+ <xsl:attribute name="gpos">
601
+ <xsl:value-of select="$gpos"/>
602
+ </xsl:attribute>
603
+ <xsl:attribute name="pos">
604
+ <xsl:value-of select="$pos"/>
605
+ </xsl:attribute>
606
+ <xsl:copy-of select="$sf/text()"/>
607
+ </marc:sf>
608
+ </xsl:when>
609
+ <xsl:when test="$df/@tag = '261' and ($sf/@code = 'a' or $sf/@code = 'b')">
610
+ <xsl:variable name="map260sfs">
611
+ <m sfCode="a">b</m>
612
+ <m sfCode="b">b</m>
613
+ </xsl:variable>
614
+ <marc:sf type="Production">
615
+ <xsl:attribute name="code">
616
+ <xsl:value-of select="exsl:node-set($map260sfs)/m[@sfCode = $sf/@code]"/>
617
+ </xsl:attribute>
618
+ <xsl:attribute name="gpos">
619
+ <xsl:value-of select="$gpos"/>
620
+ </xsl:attribute>
621
+ <xsl:attribute name="pos">
622
+ <xsl:value-of select="$pos"/>
623
+ </xsl:attribute>
624
+ <xsl:copy-of select="$sf/text()"/>
625
+ </marc:sf>
626
+ </xsl:when>
627
+ <xsl:when test="$df/@tag = '261' and $sf/@code = 'e'">
628
+ <xsl:variable name="map260sfs">
629
+ <m sfCode="e">b</m>
630
+ </xsl:variable>
631
+ <marc:sf type="Manufacture">
632
+ <xsl:attribute name="code">
633
+ <xsl:value-of select="exsl:node-set($map260sfs)/m[@sfCode = $sf/@code]"/>
634
+ </xsl:attribute>
635
+ <xsl:attribute name="gpos">
636
+ <xsl:value-of select="$gpos"/>
637
+ </xsl:attribute>
638
+ <xsl:attribute name="pos">
639
+ <xsl:value-of select="$pos"/>
640
+ </xsl:attribute>
641
+ <xsl:copy-of select="$sf/text()"/>
642
+ </marc:sf>
643
+ </xsl:when>
644
+ <xsl:when test="$df/@tag = '261' and ($sf/@code = 'd' or $sf/@code = 'f')">
645
+ <xsl:variable name="map260sfs">
646
+ <m sfCode="f">a</m>
647
+ <m sfCode="d">c</m>
648
+ </xsl:variable>
649
+ <!--<xsl:variable name="sfType">
650
+ <xsl:if test="$sf/@code = 'f'">
651
+ <xsl:choose>
652
+ <xsl:when test="$df/marc:subfield[$pos - 1][@code = 'a' or @code = 'b']">Production</xsl:when>
653
+ <xsl:when test="$df/marc:subfield[$pos - 1][@code = 'e']">Manufacture</xsl:when>
654
+ <xsl:otherwise>Publication</xsl:otherwise>
655
+ </xsl:choose>
656
+ </xsl:if>
657
+ </xsl:variable>-->
658
+ <marc:sf>
659
+ <!--<xsl:if test="$sfType != ''">
660
+ <xsl:attribute name="type">
661
+ <xsl:value-of select="$sfType"/>
662
+ </xsl:attribute>
663
+ </xsl:if>-->
664
+ <xsl:attribute name="code">
665
+ <xsl:value-of select="$map260sfs/m[@sfCode = $sf/@code]"/>
666
+ </xsl:attribute>
667
+ <xsl:attribute name="gpos">
668
+ <xsl:value-of select="$gpos"/>
669
+ </xsl:attribute>
670
+ <xsl:attribute name="pos">
671
+ <xsl:value-of select="$pos"/>
672
+ </xsl:attribute>
673
+ <xsl:copy-of select="$sf/text()"/>
674
+ </marc:sf>
675
+ </xsl:when>
676
+ <xsl:when test="$sf/@code = 'a' or $sf/@code = 'b' or $sf/@code = 'c'">
677
+ <marc:sf>
678
+ <xsl:copy-of select="$sf/@*"/>
679
+ <xsl:attribute name="gpos">
680
+ <xsl:value-of select="$gpos"/>
681
+ </xsl:attribute>
682
+ <xsl:attribute name="pos">
683
+ <xsl:value-of select="$pos"/>
684
+ </xsl:attribute>
685
+ <xsl:copy-of select="$sf/text()"/>
686
+ </marc:sf>
687
+ </xsl:when>
688
+ <xsl:when test="$sf/@code = 'e' or $sf/@code = 'f' or $sf/@code = 'g'">
689
+ <xsl:variable name="map260sfs">
690
+ <m sfCode="e">a</m>
691
+ <m sfCode="f">b</m>
692
+ <m sfCode="g">c</m>
693
+ </xsl:variable>
694
+ <marc:sf type="Manufacture">
695
+ <xsl:attribute name="code">
696
+ <xsl:value-of select="exsl:node-set($map260sfs)/m[@sfCode = $sf/@code]"/>
697
+ </xsl:attribute>
698
+ <xsl:attribute name="gpos">
699
+ <xsl:value-of select="$gpos"/>
700
+ </xsl:attribute>
701
+ <xsl:attribute name="pos">
702
+ <xsl:value-of select="$pos"/>
703
+ </xsl:attribute>
704
+ <xsl:copy-of select="$sf/text()"/>
705
+ </marc:sf>
706
+ </xsl:when>
707
+ </xsl:choose>
708
+
709
+ <xsl:variable name="next_gpos" select="$gpos + 1"/>
710
+ <xsl:variable name="next_pos" select="$pos + 1"/>
711
+
712
+ <xsl:choose>
713
+ <xsl:when
714
+ test="$df/marc:subfield[$next_pos][@code = 'b' or @code = 'c' or @code = 'd' or @code = 'f' or @code = 'g' or @code = '7']">
715
+ <xsl:call-template name="parse26x">
716
+ <xsl:with-param name="df" select="$df"/>
717
+ <xsl:with-param name="gpos" select="$gpos"/>
718
+ <xsl:with-param name="pos" select="$next_pos"/>
719
+ </xsl:call-template>
720
+ </xsl:when>
721
+ <xsl:when
722
+ test="
723
+ ($sf/@code = '6' and $df/marc:subfield[$next_pos][@code = '3' or @code = 'a'])
724
+ or
725
+ ($sf/@code = '3' and $df/marc:subfield[$next_pos][@code = 'a'])">
726
+ <xsl:call-template name="parse26x">
727
+ <xsl:with-param name="df" select="$df"/>
728
+ <xsl:with-param name="gpos" select="$gpos"/>
729
+ <xsl:with-param name="pos" select="$next_pos"/>
730
+ </xsl:call-template>
731
+ </xsl:when>
732
+ <xsl:when
733
+ test="
734
+ ($sf/@code = 'a' and $df/marc:subfield[$next_pos][@code = 'a'])
735
+ or
736
+ ($sf/@code = 'e' and $df/marc:subfield[$next_pos][@code = 'e'])">
737
+ <xsl:call-template name="parse26x">
738
+ <xsl:with-param name="df" select="$df"/>
739
+ <xsl:with-param name="gpos" select="$gpos"/>
740
+ <xsl:with-param name="pos" select="$next_pos"/>
741
+ </xsl:call-template>
742
+ </xsl:when>
743
+ <xsl:when
744
+ test="
745
+ ($sf/@code != 'a' and $df/marc:subfield[$next_pos][@code = 'a'])
746
+ or
747
+ ($sf/@code != 'e' and $df/marc:subfield[$next_pos][@code = 'e'])">
748
+ <xsl:for-each select="$df/marc:subfield[@code = '7']">
749
+ <marc:sf>
750
+ <xsl:copy-of select="@*"/>
751
+ <xsl:attribute name="gpos">
752
+ <xsl:value-of select="$gpos"/>
753
+ </xsl:attribute>
754
+ <xsl:copy-of select="text()"/>
755
+ </marc:sf>
756
+ </xsl:for-each>
757
+ <xsl:call-template name="parse26x">
758
+ <xsl:with-param name="df" select="$df"/>
759
+ <xsl:with-param name="gpos" select="$next_gpos"/>
760
+ <xsl:with-param name="pos" select="$next_pos"/>
761
+ </xsl:call-template>
762
+ </xsl:when>
763
+ </xsl:choose>
764
+ </xsl:template>
765
+
766
+ <xsl:template match="marc:controlfield[@tag = '008']" mode="process8">
767
+ <xsl:variable name="vDate1">
768
+ <xsl:choose>
769
+ <xsl:when test="substring(., 8, 4) = ' '"/>
770
+ <xsl:when test="substring(., 8, 4) = '||||'"/>
771
+ <xsl:otherwise>
772
+ <xsl:value-of select="substring(., 8.4)"/>
773
+ </xsl:otherwise>
774
+ </xsl:choose>
775
+ </xsl:variable>
776
+ <xsl:variable name="vDate2">
777
+ <xsl:choose>
778
+ <xsl:when test="substring(., 12, 4) = ' '"/>
779
+ <xsl:when test="substring(., 12, 4) = '||||'"/>
780
+ <xsl:otherwise>
781
+ <xsl:value-of select="substring(., 12, 4)"/>
782
+ </xsl:otherwise>
783
+ </xsl:choose>
784
+ </xsl:variable>
785
+ <!--
786
+ 06 - Type of date/Publication status
787
+
788
+ b - No dates given; B.C. date involved
789
+ *c - Continuing resource currently published
790
+ *d - Continuing resource ceased publication
791
+ *e - Detailed date
792
+ *i - Inclusive dates of collection
793
+ *k - Range of years of bulk of collection
794
+ *m - Multiple dates
795
+ n - Dates unknown
796
+ *p - Date of distribution/release/issue and production/recording session when different
797
+ *q - Questionable date
798
+ *r - Reprint/reissue date and original date
799
+ *s - Single known date/probable date
800
+ *t - Publication date and copyright date
801
+ *u - Continuing resource status unknown
802
+ *| - No attempt to code
803
+ -->
804
+ <xsl:variable name="provisionDate">
805
+ <xsl:choose>
806
+ <xsl:when test="substring(., 7, 1) = 'c'">
807
+ <xsl:call-template name="u2x">
808
+ <xsl:with-param name="dateString" select="concat(substring(., 8, 4), '/..')"
809
+ />
810
+ </xsl:call-template>
811
+ </xsl:when>
812
+ <xsl:when
813
+ test="
814
+ substring(., 7, 1) = 'd' or
815
+ substring(., 7, 1) = 'i' or
816
+ substring(., 7, 1) = 'k' or
817
+ substring(., 7, 1) = 'm' or
818
+ substring(., 7, 1) = 'u' or
819
+ (substring(., 7, 1) = '|' and $vDate1 != '' and $vDate2 != '')">
820
+ <xsl:call-template name="u2x">
821
+ <xsl:with-param name="dateString"
822
+ select="concat(substring(., 8, 4), '/', substring(., 12, 4))"/>
823
+ </xsl:call-template>
824
+ </xsl:when>
825
+ <xsl:when
826
+ test="substring(., 7, 1) = 'q'">
827
+ <xsl:call-template name="u2x">
828
+ <xsl:with-param name="dateString"
829
+ select="concat(substring(., 8, 4), '~/', substring(., 12, 4), '~')"/>
830
+ </xsl:call-template>
831
+ </xsl:when>
832
+ <xsl:when
833
+ test="
834
+ substring(., 7, 1) = 'e' or
835
+ (substring(., 7, 1) = '|' and $vDate1 != '' and $vDate2 != '')">
836
+ <xsl:choose>
837
+ <xsl:when test="substring(., 14, 2) = ' '">
838
+ <xsl:call-template name="u2x">
839
+ <xsl:with-param name="dateString"
840
+ select="concat(substring(., 8, 4), '-', substring(., 12, 2))"/>
841
+ </xsl:call-template>
842
+ </xsl:when>
843
+ <xsl:otherwise>
844
+ <xsl:call-template name="u2x">
845
+ <xsl:with-param name="dateString"
846
+ select="concat(substring(., 8, 4), '-', substring(., 12, 2), '-', substring(., 14, 2))"
847
+ />
848
+ </xsl:call-template>
849
+ </xsl:otherwise>
850
+ </xsl:choose>
851
+ </xsl:when>
852
+ <xsl:when
853
+ test="
854
+ substring(., 7, 1) = 'p' or
855
+ substring(., 7, 1) = 'r' or
856
+ substring(., 7, 1) = 's' or
857
+ substring(., 7, 1) = 't' or
858
+ (substring(., 7, 1) = '|' and $vDate1 != '')">
859
+ <xsl:call-template name="u2x">
860
+ <xsl:with-param name="dateString" select="substring(., 8, 4)"/>
861
+ </xsl:call-template>
862
+ </xsl:when>
863
+ <xsl:when test="substring(., 7, 1) = 'n' and $vDate1 != '' and $vDate2 != ''">
864
+ <xsl:call-template name="u2x">
865
+ <xsl:with-param name="dateString"
866
+ select="concat(substring(., 8, 4), '/', substring(., 12, 4))"/>
867
+ </xsl:call-template>
868
+ </xsl:when>
869
+ <xsl:when test="substring(., 7, 1) = 'n' and $vDate1 != ''">
870
+ <xsl:call-template name="u2x">
871
+ <xsl:with-param name="dateString"
872
+ select="substring(., 8, 4)"/>
873
+ </xsl:call-template>
874
+ </xsl:when>
875
+ <xsl:when test="substring(., 7, 1) = 'n'">XXXX</xsl:when>
876
+ </xsl:choose>
877
+ </xsl:variable>
878
+ <xsl:variable name="pubPlace">
879
+ <xsl:choose>
880
+ <xsl:when test="substring(., 18, 1) = ' '">
881
+ <xsl:value-of select="substring(., 16, 2)"/>
882
+ </xsl:when>
883
+ <xsl:otherwise>
884
+ <xsl:value-of select="substring(., 16, 3)"/>
885
+ </xsl:otherwise>
886
+ </xsl:choose>
887
+ </xsl:variable>
888
+
889
+ <xsl:choose>
890
+ <xsl:when test="$provisionDate != ''">
891
+ <paGroup>
892
+ <xsl:choose>
893
+ <xsl:when
894
+ test="
895
+ substring(., 7, 1) = 'c' or
896
+ substring(., 7, 1) = 'd' or
897
+ substring(., 7, 1) = 'e' or
898
+ substring(., 7, 1) = 'm' or
899
+ substring(., 7, 1) = 'n' or
900
+ substring(., 7, 1) = 'q' or
901
+ substring(., 7, 1) = 'r' or
902
+ substring(., 7, 1) = 's' or
903
+ substring(., 7, 1) = 't' or
904
+ substring(., 7, 1) = 'u' or
905
+ substring(., 7, 1) = '|'">
906
+ <type>Publication</type>
907
+ </xsl:when>
908
+ <xsl:when
909
+ test="
910
+ substring(., 7, 1) = 'i' or
911
+ substring(., 7, 1) = 'k'">
912
+ <type>Production</type>
913
+ <bf:note>
914
+ <bf:Note>
915
+ <xsl:choose>
916
+ <xsl:when test="substring(., 7, 1) = 'i'">
917
+ <rdfs:label>inclusive collection dates</rdfs:label>
918
+ </xsl:when>
919
+ <xsl:otherwise>
920
+ <rdfs:label>bulk collection dates</rdfs:label>
921
+ </xsl:otherwise>
922
+ </xsl:choose>
923
+ </bf:Note>
924
+ </bf:note>
925
+ </xsl:when>
926
+ <xsl:when test="substring(., 7, 1) = 'p'">
927
+ <type>Distribution</type>
928
+ </xsl:when>
929
+ </xsl:choose>
930
+ <bf:date>
931
+ <xsl:attribute name="rdf:datatype">
932
+ <xsl:value-of select="concat($edtf, 'edtf')"/>
933
+ </xsl:attribute>
934
+ <xsl:value-of select="$provisionDate"/>
935
+ </bf:date>
936
+ <xsl:choose>
937
+ <xsl:when test="substring(., 7, 1) = 'c'">
938
+ <bf:status>
939
+ <bf:Status>
940
+ <xsl:attribute name="rdf:about"
941
+ >http://id.loc.gov/vocabulary/mstatus/current</xsl:attribute>
942
+ <rdfs:label>current</rdfs:label>
943
+ </bf:Status>
944
+ </bf:status>
945
+ </xsl:when>
946
+ <xsl:when test="substring(., 7, 1) = 'd'">
947
+ <bf:status>
948
+ <bf:Status>
949
+ <xsl:attribute name="rdf:about"
950
+ >http://id.loc.gov/vocabulary/mstatus/ceased</xsl:attribute>
951
+ <rdfs:label>ceased</rdfs:label>
952
+ </bf:Status>
953
+ </bf:status>
954
+ </xsl:when>
955
+ </xsl:choose>
956
+ <xsl:if test="$pubPlace != '' and $pubPlace != '|||'">
957
+ <xsl:variable name="pubPlaceEncoded">
958
+ <xsl:call-template name="url-encode">
959
+ <xsl:with-param name="str" select="normalize-space($pubPlace)"/>
960
+ </xsl:call-template>
961
+ </xsl:variable>
962
+ <bf:place>
963
+ <xsl:attribute name="rdf:resource">
964
+ <xsl:value-of select="concat($countries, $pubPlaceEncoded)"/>
965
+ </xsl:attribute>
966
+ </bf:place>
967
+ </xsl:if>
968
+ </paGroup>
969
+ <xsl:choose>
970
+ <xsl:when test="substring(., 7, 1) = 'p'">
971
+ <paGroup>
972
+ <type>Production</type>
973
+ <bf:date>
974
+ <xsl:attribute name="rdf:datatype">
975
+ <xsl:value-of select="concat($edtf, 'edtf')"/>
976
+ </xsl:attribute>
977
+ <xsl:call-template name="u2x">
978
+ <xsl:with-param name="dateString" select="substring(., 12, 4)"/>
979
+ </xsl:call-template>
980
+ </bf:date>
981
+ </paGroup>
982
+ </xsl:when>
983
+ <xsl:when test="
984
+ substring(., 7, 1) = 't' and
985
+ substring(., 12, 4) != ' ' and
986
+ substring(., 12, 4) != '||||'
987
+ ">
988
+ <paGroup>
989
+ <type>Copyright</type>
990
+ <bf:copyrightDate>
991
+ <xsl:attribute name="rdf:datatype">
992
+ <xsl:value-of select="concat($edtf, 'edtf')"/>
993
+ </xsl:attribute>
994
+ <xsl:call-template name="u2x">
995
+ <xsl:with-param name="dateString" select="substring(., 12, 4)"/>
996
+ </xsl:call-template>
997
+ </bf:copyrightDate>
998
+ </paGroup>
999
+ </xsl:when>
1000
+ </xsl:choose>
1001
+ </xsl:when>
1002
+ <xsl:otherwise>
1003
+ <xsl:if test="$pubPlace != '' and $pubPlace != '|||'">
1004
+ <xsl:variable name="pubPlaceEncoded">
1005
+ <xsl:call-template name="url-encode">
1006
+ <xsl:with-param name="str" select="normalize-space($pubPlace)"/>
1007
+ </xsl:call-template>
1008
+ </xsl:variable>
1009
+ <paGroup>
1010
+ <type>Publication</type>
1011
+ <bf:place>
1012
+ <xsl:attribute name="rdf:resource">
1013
+ <xsl:value-of select="concat($countries, $pubPlaceEncoded)"/>
1014
+ </xsl:attribute>
1015
+ </bf:place>
1016
+ </paGroup>
1017
+ </xsl:if>
1018
+ </xsl:otherwise>
1019
+ </xsl:choose>
1020
+ </xsl:template>
1021
+ </xsl:stylesheet>