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,771 @@
1
+ <?xml version='1.0'?>
2
+ <xsl:stylesheet version="1.0"
3
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
4
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
5
+ xmlns:marc="http://www.loc.gov/MARC21/slim"
6
+ xmlns:bf="http://id.loc.gov/ontologies/bibframe/"
7
+ xmlns:bflc="http://id.loc.gov/ontologies/bflc/"
8
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9
+ xmlns:madsrdf="http://www.loc.gov/mads/rdf/v1#"
10
+ exclude-result-prefixes="xsl marc">
11
+
12
+ <!--
13
+ Conversion specs for bib title fields 210-247 (not 240)
14
+ -->
15
+
16
+ <!-- bf:Instance properties from MARC 210 -->
17
+ <xsl:template match="marc:datafield[@tag='210' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='210')]" mode="instance">
18
+ <xsl:param name="serialization" select="'rdfxml'"/>
19
+ <xsl:if test="@ind2='0'">
20
+ <xsl:apply-templates mode="title210" select=".">
21
+ <xsl:with-param name="serialization" select="$serialization"/>
22
+ </xsl:apply-templates>
23
+ </xsl:if>
24
+ </xsl:template>
25
+
26
+ <!-- bf:Work properties from MARC 210 -->
27
+ <xsl:template match="marc:datafield[@tag='210' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='210')]" mode="work">
28
+ <xsl:param name="serialization" select="'rdfxml'"/>
29
+ <xsl:if test="@ind2=' '">
30
+ <xsl:apply-templates mode="title210" select=".">
31
+ <xsl:with-param name="serialization" select="$serialization"/>
32
+ </xsl:apply-templates>
33
+ </xsl:if>
34
+ </xsl:template>
35
+
36
+ <!-- bf:title property from MARC 210 -->
37
+ <xsl:template match="marc:datafield[@tag='210' or @tag='880']" mode="title210">
38
+ <xsl:param name="serialization"/>
39
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
40
+ <xsl:choose>
41
+ <xsl:when test="$serialization = 'rdfxml'">
42
+ <bf:title>
43
+ <bf:AbbreviatedTitle>
44
+ <xsl:for-each select="marc:subfield[@code='a']">
45
+ <bf:mainTitle>
46
+ <xsl:if test="$vXmlLang != ''">
47
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
48
+ </xsl:if>
49
+ <xsl:value-of select="."/>
50
+ </bf:mainTitle>
51
+ </xsl:for-each>
52
+ <xsl:for-each select="marc:subfield[@code='b']">
53
+ <bf:qualifier>
54
+ <xsl:if test="$vXmlLang != ''">
55
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
56
+ </xsl:if>
57
+ <xsl:value-of select="."/>
58
+ </bf:qualifier>
59
+ </xsl:for-each>
60
+ <xsl:choose>
61
+ <xsl:when test="@ind2='0'">
62
+ <xsl:for-each select="marc:subfield[@code='2']">
63
+ <bf:assigner>
64
+ <bf:Agent>
65
+ <bf:code><xsl:value-of select="."/></bf:code>
66
+ </bf:Agent>
67
+ </bf:assigner>
68
+ </xsl:for-each>
69
+ </xsl:when>
70
+ <xsl:when test="@ind2=' '">
71
+ <bf:assigner>
72
+ <bf:Agent>
73
+ <bf:code>issnkey</bf:code>
74
+ </bf:Agent>
75
+ </bf:assigner>
76
+ </xsl:when>
77
+ </xsl:choose>
78
+ </bf:AbbreviatedTitle>
79
+ </bf:title>
80
+ </xsl:when>
81
+ </xsl:choose>
82
+ </xsl:template>
83
+
84
+ <!-- bf:Work properties from MARC 222 -->
85
+ <xsl:template match="marc:datafield[@tag='222' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='222')]" mode="work">
86
+ <xsl:param name="serialization" select="'rdfxml'"/>
87
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
88
+ <xsl:choose>
89
+ <xsl:when test="$serialization = 'rdfxml'">
90
+ <bf:title>
91
+ <bf:KeyTitle>
92
+ <xsl:if test="@ind2 != '0' and @ind2 != ' '">
93
+ <bflc:nonSortNum>
94
+ <xsl:if test="$vXmlLang != ''">
95
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
96
+ </xsl:if>
97
+ <xsl:value-of select="@ind2"/>
98
+ </bflc:nonSortNum>
99
+ </xsl:if>
100
+ <xsl:for-each select="marc:subfield[@code='a']">
101
+ <bf:mainTitle>
102
+ <xsl:if test="$vXmlLang != ''">
103
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
104
+ </xsl:if>
105
+ <xsl:value-of select="."/>
106
+ </bf:mainTitle>
107
+ </xsl:for-each>
108
+ <xsl:for-each select="marc:subfield[@code='b']">
109
+ <bf:qualifier>
110
+ <xsl:if test="$vXmlLang != ''">
111
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
112
+ </xsl:if>
113
+ <xsl:value-of select="."/>
114
+ </bf:qualifier>
115
+ </xsl:for-each>
116
+ </bf:KeyTitle>
117
+ </bf:title>
118
+ </xsl:when>
119
+ </xsl:choose>
120
+ </xsl:template>
121
+
122
+ <!-- bf:Instance properties from MARC 242 -->
123
+ <xsl:template match="marc:datafield[@tag='242' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='242')]" mode="instance">
124
+ <xsl:param name="serialization" select="'rdfxml'"/>
125
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
126
+ <xsl:choose>
127
+ <xsl:when test="$serialization = 'rdfxml'">
128
+ <bf:title>
129
+ <bf:VariantTitle>
130
+ <rdf:type rdf:resource="{concat($varianttitle, 'tra')}" />
131
+ <xsl:if test="@ind2 != '0' and @ind2 != ' '">
132
+ <bflc:nonSortNum>
133
+ <xsl:if test="$vXmlLang != ''">
134
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
135
+ </xsl:if>
136
+ <xsl:value-of select="@ind2"/>
137
+ </bflc:nonSortNum>
138
+ </xsl:if>
139
+ <xsl:for-each select="marc:subfield[@code='a']">
140
+ <bf:mainTitle>
141
+ <xsl:if test="$vXmlLang != ''">
142
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
143
+ </xsl:if>
144
+ <xsl:call-template name="tChopPunct">
145
+ <xsl:with-param name="pString" select="."/>
146
+ </xsl:call-template>
147
+ </bf:mainTitle>
148
+ </xsl:for-each>
149
+ <xsl:for-each select="marc:subfield[@code='b']">
150
+ <bf:subtitle>
151
+ <xsl:if test="$vXmlLang != ''">
152
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
153
+ </xsl:if>
154
+ <xsl:call-template name="tChopPunct">
155
+ <xsl:with-param name="pString" select="."/>
156
+ </xsl:call-template>
157
+ </bf:subtitle>
158
+ </xsl:for-each>
159
+ <xsl:for-each select="marc:subfield[@code='n']">
160
+ <bf:partNumber>
161
+ <xsl:if test="$vXmlLang != ''">
162
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
163
+ </xsl:if>
164
+ <xsl:call-template name="tChopPunct">
165
+ <xsl:with-param name="pString" select="."/>
166
+ </xsl:call-template>
167
+ </bf:partNumber>
168
+ </xsl:for-each>
169
+ <xsl:for-each select="marc:subfield[@code='p']">
170
+ <bf:partName>
171
+ <xsl:if test="$vXmlLang != ''">
172
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
173
+ </xsl:if>
174
+ <xsl:call-template name="tChopPunct">
175
+ <xsl:with-param name="pString" select="."/>
176
+ </xsl:call-template>
177
+ </bf:partName>
178
+ </xsl:for-each>
179
+ </bf:VariantTitle>
180
+ </bf:title>
181
+ </xsl:when>
182
+ </xsl:choose>
183
+ </xsl:template>
184
+
185
+ <!-- bf:Work properties from MARC 243 -->
186
+ <xsl:template match="marc:datafield[@tag='243' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='243')]" mode="work">
187
+ <xsl:param name="serialization" select="'rdfxml'"/>
188
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
189
+ <xsl:choose>
190
+ <xsl:when test="$serialization = 'rdfxml'">
191
+ <bf:title>
192
+ <bf:CollectiveTitle>
193
+ <xsl:if test="@ind2 != '0' and @ind2 != ' '">
194
+ <bflc:nonSortNum>
195
+ <xsl:if test="$vXmlLang != ''">
196
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
197
+ </xsl:if>
198
+ <xsl:value-of select="@ind2"/>
199
+ </bflc:nonSortNum>
200
+ </xsl:if>
201
+ <xsl:for-each select="marc:subfield[@code='a']">
202
+ <bf:mainTitle>
203
+ <xsl:if test="$vXmlLang != ''">
204
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
205
+ </xsl:if>
206
+ <xsl:call-template name="tChopPunct">
207
+ <xsl:with-param name="pString" select="."/>
208
+ </xsl:call-template>
209
+ </bf:mainTitle>
210
+ </xsl:for-each>
211
+ </bf:CollectiveTitle>
212
+ </bf:title>
213
+ </xsl:when>
214
+ </xsl:choose>
215
+ </xsl:template>
216
+
217
+ <!-- bf:Work properties from MARC 245 -->
218
+ <xsl:template match="marc:datafield[@tag='245' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='245')]" mode="work">
219
+ <xsl:param name="serialization" select="'rdfxml'"/>
220
+ <xsl:variable name="vOccurrence">
221
+ <xsl:value-of select="substring(substring-after(marc:subfield[@code='6'],'-'),1,2)"/>
222
+ </xsl:variable>
223
+ <xsl:variable name="label">
224
+ <xsl:apply-templates mode="concat-nodes-space"
225
+ select="marc:subfield[@code='a' or
226
+ @code='b' or
227
+ @code='n' or
228
+ @code='p']"/>
229
+ </xsl:variable>
230
+ <xsl:variable name="vLinkedLabel">
231
+ <xsl:if test="@tag='245' and marc:subfield[@code='6']">
232
+ <xsl:apply-templates mode="concat-nodes-space"
233
+ select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='245' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]/marc:subfield[@code='a' or
234
+ @code='b' or
235
+ @code='n' or
236
+ @code='p']"/>
237
+ </xsl:if>
238
+ </xsl:variable>
239
+ <xsl:variable name="vXmlLang880">
240
+ <xsl:if test="@tag='245' and marc:subfield[@code='6']">
241
+ <xsl:apply-templates select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='245' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]" mode="xmllang"/>
242
+ </xsl:if>
243
+ </xsl:variable>
244
+ <!-- generate Work properties -->
245
+ <xsl:apply-templates mode="work245" select=".">
246
+ <xsl:with-param name="serialization" select="$serialization"/>
247
+ </xsl:apply-templates>
248
+ <!-- generate Work properties from linked 880 -->
249
+ <xsl:if test="@tag='245' and marc:subfield[@code='6']">
250
+ <xsl:apply-templates mode="work245" select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='245' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]">
251
+ <xsl:with-param name="serialization" select="$serialization"/>
252
+ </xsl:apply-templates>
253
+ </xsl:if>
254
+ <xsl:choose>
255
+ <xsl:when test="$serialization='rdfxml'">
256
+ <bf:title>
257
+ <bf:Title>
258
+ <xsl:if test="@ind2 != '0' and @ind2 != ' '">
259
+ <bflc:nonSortNum>
260
+ <xsl:if test="$vXmlLang880 != ''">
261
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang880"/></xsl:attribute>
262
+ </xsl:if>
263
+ <xsl:value-of select="@ind2" />
264
+ </bflc:nonSortNum>
265
+ </xsl:if>
266
+ <bf:mainTitle>
267
+ <xsl:call-template name="tChopPunct">
268
+ <xsl:with-param name="pString" select="$label"/>
269
+ </xsl:call-template>
270
+ </bf:mainTitle>
271
+ <xsl:if test="$vLinkedLabel != ''">
272
+ <bf:mainTitle>
273
+ <xsl:if test="$vXmlLang880 != ''">
274
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang880"/></xsl:attribute>
275
+ </xsl:if>
276
+ <xsl:call-template name="tChopPunct">
277
+ <xsl:with-param name="pString" select="$vLinkedLabel"/>
278
+ </xsl:call-template>
279
+ </bf:mainTitle>
280
+ </xsl:if>
281
+ <!--
282
+ <xsl:apply-templates mode="title245" select=".">
283
+ <xsl:with-param name="serialization" select="$serialization"/>
284
+ <xsl:with-param name="pSubtitle" select="false()"/>
285
+ <xsl:with-param name="label" select="$label"/>
286
+ </xsl:apply-templates>
287
+ <!-\- generate Title properties from linked 880 -\->
288
+ <xsl:if test="@tag='245' and marc:subfield[@code='6']">
289
+ <xsl:apply-templates mode="title245" select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='245' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]">
290
+ <xsl:with-param name="serialization" select="$serialization"/>
291
+ <xsl:with-param name="pSubtitle" select="false()"/>
292
+ <xsl:with-param name="label" select="$vLinkedLabel"/>
293
+ </xsl:apply-templates>
294
+ </xsl:if>
295
+ -->
296
+ </bf:Title>
297
+ </bf:title>
298
+ </xsl:when>
299
+ </xsl:choose>
300
+ </xsl:template>
301
+
302
+ <xsl:template match="marc:datafield[@tag='245' or @tag='880']" mode="work245">
303
+ <xsl:param name="serialization" select="'rdfxml'"/>
304
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
305
+ <xsl:choose>
306
+ <xsl:when test="$serialization = 'rdfxml'">
307
+ <xsl:if test="not(../marc:datafield[@tag='046']/marc:subfield[@code='k'])">
308
+ <xsl:for-each select="marc:subfield[@code='f']">
309
+ <bf:originDate>
310
+ <xsl:if test="$vXmlLang != ''">
311
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
312
+ </xsl:if>
313
+ <xsl:call-template name="tChopPunct">
314
+ <xsl:with-param name="pString" select="."/>
315
+ <xsl:with-param name="pForceTerm" select="true()"/>
316
+ </xsl:call-template>
317
+ </bf:originDate>
318
+ </xsl:for-each>
319
+ </xsl:if>
320
+ <xsl:for-each select="marc:subfield[@code='g']">
321
+ <bf:originDate>
322
+ <xsl:if test="$vXmlLang != ''">
323
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
324
+ </xsl:if>
325
+ <xsl:call-template name="tChopPunct">
326
+ <xsl:with-param name="pString" select="."/>
327
+ <xsl:with-param name="pForceTerm" select="true()"/>
328
+ </xsl:call-template>
329
+ </bf:originDate>
330
+ </xsl:for-each>
331
+ <xsl:for-each select="marc:subfield[@code='s']">
332
+ <bf:version>
333
+ <xsl:if test="$vXmlLang != ''">
334
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
335
+ </xsl:if>
336
+ <xsl:call-template name="tChopPunct">
337
+ <xsl:with-param name="pString" select="."/>
338
+ </xsl:call-template>
339
+ </bf:version>
340
+ </xsl:for-each>
341
+ </xsl:when>
342
+ </xsl:choose>
343
+ </xsl:template>
344
+
345
+ <!-- bf:Instance properties from MARC 245 -->
346
+ <xsl:template match="marc:datafield[@tag='245' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='245')]" mode="instance">
347
+ <xsl:param name="serialization" select="'rdfxml'"/>
348
+ <xsl:param name="pInstanceType" />
349
+ <xsl:variable name="output245">
350
+ <xsl:choose>
351
+ <xsl:when test="$pInstanceType = 'SecondaryInstance' and ../marc:datafield[@tag='856' or @tag='859']">SKIP</xsl:when>
352
+ <xsl:when test="$pInstanceType != 'SecondaryInstance'">TRUE</xsl:when>
353
+ <xsl:otherwise>TRUE</xsl:otherwise>
354
+ </xsl:choose>
355
+ </xsl:variable>
356
+ <xsl:if test="$output245!='SKIP'">
357
+ <xsl:variable name="vOccurrence">
358
+ <xsl:value-of select="substring(substring-after(marc:subfield[@code='6'],'-'),1,2)"/>
359
+ </xsl:variable>
360
+ <xsl:variable name="label">
361
+ <xsl:apply-templates mode="concat-nodes-space"
362
+ select="marc:subfield[@code='a' or
363
+ @code='b' or
364
+ @code='f' or
365
+ @code='g' or
366
+ @code='k' or
367
+ @code='n' or
368
+ @code='p' or
369
+ @code='s']"/>
370
+ </xsl:variable>
371
+ <xsl:variable name="vLinkedLabel">
372
+ <xsl:if test="@tag='245' and marc:subfield[@code='6']">
373
+ <xsl:apply-templates mode="concat-nodes-space"
374
+ select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='245' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]/marc:subfield[@code='a' or
375
+ @code='b' or
376
+ @code='f' or
377
+ @code='g' or
378
+ @code='k' or
379
+ @code='n' or
380
+ @code='p' or
381
+ @code='s']"/>
382
+ </xsl:if>
383
+ </xsl:variable>
384
+ <xsl:apply-templates mode="instance245" select=".">
385
+ <xsl:with-param name="serialization" select="$serialization"/>
386
+ <xsl:with-param name="label" select="$label"/>
387
+ </xsl:apply-templates>
388
+ <!-- generate Instance properties from linked 880 -->
389
+ <xsl:if test="@tag='245' and marc:subfield[@code='6']">
390
+ <xsl:apply-templates mode="instance245" select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='245' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]">
391
+ <xsl:with-param name="serialization" select="$serialization"/>
392
+ <xsl:with-param name="label" select="$vLinkedLabel"/>
393
+ </xsl:apply-templates>
394
+ </xsl:if>
395
+ <xsl:choose>
396
+ <xsl:when test="$serialization='rdfxml'">
397
+ <bf:title>
398
+ <bf:Title>
399
+ <xsl:apply-templates mode="title245" select=".">
400
+ <xsl:with-param name="serialization" select="$serialization"/>
401
+ <xsl:with-param name="label" select="$label"/>
402
+ </xsl:apply-templates>
403
+ <!-- generate Title properties from linked 880 -->
404
+ <xsl:if test="@tag='245' and marc:subfield[@code='6']">
405
+ <xsl:apply-templates mode="title245" select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='245' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]">
406
+ <xsl:with-param name="serialization" select="$serialization"/>
407
+ <xsl:with-param name="label" select="$vLinkedLabel"/>
408
+ </xsl:apply-templates>
409
+ </xsl:if>
410
+ </bf:Title>
411
+ </bf:title>
412
+ </xsl:when>
413
+ </xsl:choose>
414
+ </xsl:if>
415
+ </xsl:template>
416
+
417
+ <xsl:template match="marc:datafield[@tag='245' or @tag='880']" mode="instance245">
418
+ <xsl:param name="serialization"/>
419
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
420
+ <xsl:choose>
421
+ <xsl:when test="$serialization = 'rdfxml'">
422
+ <xsl:for-each select="marc:subfield[@code='c']">
423
+ <bf:responsibilityStatement>
424
+ <xsl:if test="$vXmlLang != ''">
425
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
426
+ </xsl:if>
427
+ <xsl:call-template name="tChopPunct">
428
+ <xsl:with-param name="pString" select="."/>
429
+ </xsl:call-template>
430
+ </bf:responsibilityStatement>
431
+ </xsl:for-each>
432
+ </xsl:when>
433
+ </xsl:choose>
434
+ </xsl:template>
435
+
436
+ <!-- bf:Title from MARC 245 -->
437
+ <xsl:template match="marc:datafield[@tag='245' or @tag='880']" mode="title245">
438
+ <xsl:param name="label"/>
439
+ <xsl:param name="serialization" select="'rdfxml'"/>
440
+ <xsl:param name="pSubtitle" select="true()"/>
441
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
442
+ <xsl:choose>
443
+ <xsl:when test="$serialization = 'rdfxml'">
444
+ <xsl:if test="@ind2 != '0' and @ind2 != ' '">
445
+ <bflc:nonSortNum>
446
+ <xsl:if test="$vXmlLang != ''">
447
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
448
+ </xsl:if>
449
+ <xsl:value-of select="@ind2" />
450
+ </bflc:nonSortNum>
451
+ </xsl:if>
452
+ <xsl:for-each select="marc:subfield[@code='a']">
453
+ <bf:mainTitle>
454
+ <xsl:if test="$vXmlLang != ''">
455
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
456
+ </xsl:if>
457
+ <xsl:call-template name="tChopPunct">
458
+ <xsl:with-param name="pString" select="."/>
459
+ </xsl:call-template>
460
+ </bf:mainTitle>
461
+ </xsl:for-each>
462
+ <!-- No subtitle in Work title object -->
463
+ <xsl:choose>
464
+ <xsl:when test="$pSubtitle">
465
+ <xsl:for-each select="marc:subfield[@code='b']">
466
+ <bf:subtitle>
467
+ <xsl:if test="$vXmlLang != ''">
468
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
469
+ </xsl:if>
470
+ <xsl:call-template name="tChopPunct">
471
+ <xsl:with-param name="pString" select="."/>
472
+ </xsl:call-template>
473
+ </bf:subtitle>
474
+ </xsl:for-each>
475
+ </xsl:when>
476
+ </xsl:choose>
477
+ <xsl:for-each select="marc:subfield[@code='n']">
478
+ <bf:partNumber>
479
+ <xsl:if test="$vXmlLang != ''">
480
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
481
+ </xsl:if>
482
+ <xsl:call-template name="tChopPunct">
483
+ <xsl:with-param name="pString" select="."/>
484
+ </xsl:call-template>
485
+ </bf:partNumber>
486
+ </xsl:for-each>
487
+ <xsl:for-each select="marc:subfield[@code='p']">
488
+ <bf:partName>
489
+ <xsl:if test="$vXmlLang != ''">
490
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
491
+ </xsl:if>
492
+ <xsl:call-template name="tChopPunct">
493
+ <xsl:with-param name="pString" select="."/>
494
+ </xsl:call-template>
495
+ </bf:partName>
496
+ </xsl:for-each>
497
+ </xsl:when>
498
+ </xsl:choose>
499
+ </xsl:template>
500
+
501
+ <!-- bf:Work properties from MARC 246 -->
502
+ <xsl:template match="marc:datafield[@tag='246' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='246')]" mode="work">
503
+ <xsl:param name="serialization" select="'rdfxml'"/>
504
+ <xsl:param name="pHasItem" select="false()"/>
505
+ <!-- note special $5 processing for LoC below -->
506
+ <xsl:if test="$pHasItem or not($localfields and marc:subfield[@code='5'])">
507
+ <xsl:if test="translate(@ind2,' 0123567','') = ''">
508
+ <xsl:apply-templates select="." mode="title246">
509
+ <xsl:with-param name="serialization" select="$serialization"/>
510
+ </xsl:apply-templates>
511
+ </xsl:if>
512
+ </xsl:if>
513
+ </xsl:template>
514
+
515
+ <!-- bf:Instance properties from MARC 246 -->
516
+ <xsl:template match="marc:datafield[@tag='246' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='246')]" mode="instance">
517
+ <xsl:param name="serialization" select="'rdfxml'"/>
518
+ <xsl:param name="pHasItem" select="false()"/>
519
+ <!-- note special $5 processing for LoC below -->
520
+ <xsl:if test="$pHasItem or not($localfields and marc:subfield[@code='5'])">
521
+ <xsl:if test="translate(@ind2,'48','') = ''">
522
+ <xsl:apply-templates select="." mode="title246">
523
+ <xsl:with-param name="serialization" select="$serialization"/>
524
+ </xsl:apply-templates>
525
+ </xsl:if>
526
+ </xsl:if>
527
+ </xsl:template>
528
+
529
+ <!-- title processing for MARC 246 -->
530
+ <xsl:template match="marc:datafield[@tag='246' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='246')]" mode="title246">
531
+ <xsl:param name="serialization" select="'rdfxml'"/>
532
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
533
+ <xsl:variable name="vTitleClass">
534
+ <xsl:choose>
535
+ <xsl:when test="@ind2 = '1'">bf:ParallelTitle</xsl:when>
536
+ <xsl:otherwise>bf:VariantTitle</xsl:otherwise>
537
+ </xsl:choose>
538
+ </xsl:variable>
539
+ <xsl:choose>
540
+ <xsl:when test="$serialization = 'rdfxml'">
541
+ <bf:title>
542
+ <xsl:element name="{$vTitleClass}">
543
+ <xsl:choose>
544
+ <xsl:when test="@ind2 = '0'">
545
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/por" />
546
+ </xsl:when>
547
+ <xsl:when test="@ind2 = '2'">
548
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/dis" />
549
+ </xsl:when>
550
+ <xsl:when test="@ind2 = '4'">
551
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/cov" />
552
+ </xsl:when>
553
+ <xsl:when test="@ind2 = '5'">
554
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/atp" />
555
+ </xsl:when>
556
+ <xsl:when test="@ind2 = '6'">
557
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/cap" />
558
+ </xsl:when>
559
+ <xsl:when test="@ind2 = '7'">
560
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/run" />
561
+ </xsl:when>
562
+ <xsl:when test="@ind2 = '8'">
563
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/spi" />
564
+ </xsl:when>
565
+ </xsl:choose>
566
+ <xsl:apply-templates mode="t246Props" select=".">
567
+ <xsl:with-param name="serialization" select="$serialization"/>
568
+ </xsl:apply-templates>
569
+ <!-- generate Title properties from linked 880 -->
570
+ <xsl:if test="marc:subfield[@code='6'] and not(contains(marc:subfield[@code='6'], '-00'))">
571
+ <xsl:variable name="vOccurrence">
572
+ <xsl:value-of select="substring(substring-after(marc:subfield[@code='6'],'-'),1,2)"/>
573
+ </xsl:variable>
574
+ <xsl:apply-templates mode="t246Props" select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='246' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]">
575
+ <xsl:with-param name="serialization" select="$serialization"/>
576
+ </xsl:apply-templates>
577
+ </xsl:if>
578
+ <xsl:apply-templates mode="subfield5" select="marc:subfield[@code='5']">
579
+ <xsl:with-param name="serialization" select="$serialization"/>
580
+ </xsl:apply-templates>
581
+ </xsl:element>
582
+ </bf:title>
583
+ </xsl:when>
584
+ </xsl:choose>
585
+ </xsl:template>
586
+
587
+
588
+ <xsl:template match="marc:datafield[@tag='246' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='246')]" mode="t246Props">
589
+ <xsl:param name="serialization" select="'rdfxml'"/>
590
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
591
+ <xsl:for-each select="marc:subfield[@code='i']">
592
+ <bf:note>
593
+ <bf:Note>
594
+ <rdfs:label>
595
+ <xsl:if test="$vXmlLang != ''">
596
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
597
+ </xsl:if>
598
+ <xsl:call-template name="tChopPunct">
599
+ <xsl:with-param name="pString" select="."/>
600
+ </xsl:call-template>
601
+ </rdfs:label>
602
+ </bf:Note>
603
+ </bf:note>
604
+ </xsl:for-each>
605
+ <xsl:for-each select="marc:subfield[@code='a']">
606
+ <bf:mainTitle>
607
+ <xsl:if test="$vXmlLang != ''">
608
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
609
+ </xsl:if>
610
+ <xsl:call-template name="tChopPunct">
611
+ <xsl:with-param name="pString" select="."/>
612
+ </xsl:call-template>
613
+ </bf:mainTitle>
614
+ </xsl:for-each>
615
+ <xsl:for-each select="marc:subfield[@code='b']">
616
+ <bf:subtitle>
617
+ <xsl:if test="$vXmlLang != ''">
618
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
619
+ </xsl:if>
620
+ <xsl:call-template name="tChopPunct">
621
+ <xsl:with-param name="pString" select="."/>
622
+ </xsl:call-template>
623
+ </bf:subtitle>
624
+ </xsl:for-each>
625
+ <xsl:for-each select="marc:subfield[@code='f']">
626
+ <bf:date>
627
+ <xsl:if test="$vXmlLang != ''">
628
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
629
+ </xsl:if>
630
+ <xsl:call-template name="tChopPunct">
631
+ <xsl:with-param name="pString" select="."/>
632
+ <xsl:with-param name="pForceTerm" select="true()"/>
633
+ </xsl:call-template>
634
+ </bf:date>
635
+ </xsl:for-each>
636
+ <xsl:for-each select="marc:subfield[@code='n']">
637
+ <bf:partNumber>
638
+ <xsl:if test="$vXmlLang != ''">
639
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
640
+ </xsl:if>
641
+ <xsl:call-template name="tChopPunct">
642
+ <xsl:with-param name="pString" select="."/>
643
+ </xsl:call-template>
644
+ </bf:partNumber>
645
+ </xsl:for-each>
646
+ <xsl:for-each select="marc:subfield[@code='p']">
647
+ <bf:partName>
648
+ <xsl:if test="$vXmlLang != ''">
649
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
650
+ </xsl:if>
651
+ <xsl:call-template name="tChopPunct">
652
+ <xsl:with-param name="pString" select="."/>
653
+ </xsl:call-template>
654
+ </bf:partName>
655
+ </xsl:for-each>
656
+ </xsl:template>
657
+
658
+ <!-- bf:Work properties from MARC 247 -->
659
+ <xsl:template match="marc:datafield[@tag='247' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='247')]" mode="work">
660
+ <xsl:param name="serialization" select="'rdfxml'"/>
661
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
662
+ <xsl:choose>
663
+ <xsl:when test="$serialization = 'rdfxml'">
664
+ <bf:title>
665
+ <bf:VariantTitle>
666
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/vartitletype/for" />
667
+ <xsl:apply-templates mode="t247Props" select=".">
668
+ <xsl:with-param name="serialization" select="$serialization"/>
669
+ </xsl:apply-templates>
670
+ <!-- generate Title properties from linked 880 -->
671
+ <xsl:if test="marc:subfield[@code='6'] and not(contains(marc:subfield[@code='6'], '-00'))">
672
+ <xsl:variable name="vOccurrence">
673
+ <xsl:value-of select="substring(substring-after(marc:subfield[@code='6'],'-'),1,2)"/>
674
+ </xsl:variable>
675
+ <xsl:apply-templates mode="t247Props" select="../marc:datafield[@tag='880' and substring(marc:subfield[@code='6'],1,3)='247' and substring(substring-after(marc:subfield[@code='6'],'-'),1,2)=$vOccurrence]">
676
+ <xsl:with-param name="serialization" select="$serialization"/>
677
+ </xsl:apply-templates>
678
+ </xsl:if>
679
+ <xsl:variable name="vPos" select="count(preceding-sibling::marc:datafield[@tag='247']) + 1" />
680
+ <xsl:if test="../marc:datafield[@tag='547'][$vPos]">
681
+ <bf:note>
682
+ <bf:Note>
683
+ <xsl:apply-templates select="../marc:datafield[@tag='547'][$vPos]" mode="instanceNote5XXLabel" />
684
+ </bf:Note>
685
+ </bf:note>
686
+ </xsl:if>
687
+ </bf:VariantTitle>
688
+ </bf:title>
689
+ </xsl:when>
690
+ </xsl:choose>
691
+ </xsl:template>
692
+
693
+ <xsl:template match="marc:datafield[@tag='247' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='247')]" mode="t247Props">
694
+ <xsl:param name="serialization" select="'rdfxml'"/>
695
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
696
+ <xsl:for-each select="marc:subfield[@code='a']">
697
+ <bf:mainTitle>
698
+ <xsl:if test="$vXmlLang != ''">
699
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
700
+ </xsl:if>
701
+ <xsl:call-template name="tChopPunct">
702
+ <xsl:with-param name="pString" select="."/>
703
+ </xsl:call-template>
704
+ </bf:mainTitle>
705
+ </xsl:for-each>
706
+ <xsl:for-each select="marc:subfield[@code='b']">
707
+ <bf:subtitle>
708
+ <xsl:if test="$vXmlLang != ''">
709
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
710
+ </xsl:if>
711
+ <xsl:call-template name="tChopPunct">
712
+ <xsl:with-param name="pString" select="."/>
713
+ </xsl:call-template>
714
+ </bf:subtitle>
715
+ </xsl:for-each>
716
+ <xsl:for-each select="marc:subfield[@code='f']">
717
+ <bf:date>
718
+ <xsl:if test="$vXmlLang != ''">
719
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
720
+ </xsl:if>
721
+ <xsl:call-template name="tChopPunct">
722
+ <xsl:with-param name="pString" select="."/>
723
+ <xsl:with-param name="pForceTerm" select="true()"/>
724
+ </xsl:call-template>
725
+ </bf:date>
726
+ </xsl:for-each>
727
+ <xsl:for-each select="marc:subfield[@code='g']">
728
+ <bf:qualifier>
729
+ <xsl:if test="$vXmlLang != ''">
730
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
731
+ </xsl:if>
732
+ <xsl:call-template name="tChopPunct">
733
+ <xsl:with-param name="pString" select="."/>
734
+ <xsl:with-param name="pChopParens" select="true()"/>
735
+ </xsl:call-template>
736
+ </bf:qualifier>
737
+ </xsl:for-each>
738
+ <xsl:for-each select="marc:subfield[@code='n']">
739
+ <bf:partNumber>
740
+ <xsl:if test="$vXmlLang != ''">
741
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
742
+ </xsl:if>
743
+ <xsl:call-template name="tChopPunct">
744
+ <xsl:with-param name="pString" select="."/>
745
+ </xsl:call-template>
746
+ </bf:partNumber>
747
+ </xsl:for-each>
748
+ <xsl:for-each select="marc:subfield[@code='p']">
749
+ <bf:partName>
750
+ <xsl:if test="$vXmlLang != ''">
751
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
752
+ </xsl:if>
753
+ <xsl:call-template name="tChopPunct">
754
+ <xsl:with-param name="pString" select="."/>
755
+ </xsl:call-template>
756
+ </bf:partName>
757
+ </xsl:for-each>
758
+ <xsl:for-each select="marc:subfield[@code='x']">
759
+ <bf:identifiedBy>
760
+ <bf:Issn>
761
+ <rdf:value>
762
+ <xsl:call-template name="tChopPunct">
763
+ <xsl:with-param name="pString" select="."/>
764
+ </xsl:call-template>
765
+ </rdf:value>
766
+ </bf:Issn>
767
+ </bf:identifiedBy>
768
+ </xsl:for-each>
769
+ </xsl:template>
770
+
771
+ </xsl:stylesheet>