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,713 @@
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:madsrdf="http://www.loc.gov/mads/rdf/v1#"
9
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10
+ exclude-result-prefixes="xsl marc">
11
+
12
+ <!--
13
+ Conversion specs for 050-088
14
+ -->
15
+
16
+ <xsl:template match="marc:datafield[@tag='050' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='050')]" mode="work">
17
+ <xsl:param name="serialization" select="'rdfxml'"/>
18
+ <xsl:choose>
19
+ <xsl:when test="$serialization = 'rdfxml'">
20
+ <xsl:for-each select="marc:subfield[@code='a']">
21
+ <xsl:variable name="vCurrentNode" select="generate-id(.)"/>
22
+ <xsl:variable name="vCurrentNodeUri">
23
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
24
+ <xsl:if test="position() = 1">
25
+ <xsl:choose>
26
+ <xsl:when test="starts-with(.,'(uri)')">
27
+ <xsl:value-of select="substring-after(.,'(uri)')"/>
28
+ </xsl:when>
29
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
30
+ </xsl:choose>
31
+ </xsl:if>
32
+ </xsl:for-each>
33
+ </xsl:variable>
34
+ <bf:classification>
35
+ <bf:ClassificationLcc>
36
+ <!-- If there is a currentNodeUri *and* there is no item portion, we can use a URI, I guess. -->
37
+ <xsl:if test="$vCurrentNodeUri != '' and not(../marc:subfield[@code='b'][position()=1])">
38
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vCurrentNodeUri"/></xsl:attribute>
39
+ </xsl:if>
40
+ <bf:classificationPortion>
41
+ <xsl:value-of select="."/>
42
+ </bf:classificationPortion>
43
+ <xsl:if test="position() = 1">
44
+ <xsl:for-each select="../marc:subfield[@code='b'][position()=1]">
45
+ <bf:itemPortion>
46
+ <xsl:value-of select="."/>
47
+ </bf:itemPortion>
48
+ </xsl:for-each>
49
+ </xsl:if>
50
+ <xsl:if test="../@ind2 = '0' or
51
+ (../@ind2 = ' ' and contains(ancestor::marc:record/marc:datafield[@tag='040']/marc:subfield[@code='a'][1], 'DLC'))
52
+ ">
53
+ <bf:assigner>
54
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($organizations,'dlc')"/></xsl:attribute>
55
+ </bf:assigner>
56
+ <xsl:choose>
57
+ <xsl:when test="../@ind1 = '0'">
58
+ <bf:status>
59
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($mstatus,'uba')"/></xsl:attribute>
60
+ </bf:status>
61
+ </xsl:when>
62
+ <xsl:when test="../@ind1 = '1'">
63
+ <bf:status>
64
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($mstatus,'nuba')"/></xsl:attribute>
65
+ </bf:status>
66
+ </xsl:when>
67
+ </xsl:choose>
68
+ </xsl:if>
69
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
70
+ <xsl:if test="(position() = 1 and $vCurrentNodeUri != '' and ../marc:subfield[@code='b'][position()=1])
71
+ or
72
+ position() != 1">
73
+ <madsrdf:hasRelatedAuthority>
74
+ <xsl:attribute name="rdf:resource">
75
+ <xsl:apply-templates select="." mode="generateUriFrom0">
76
+ <xsl:with-param name="serialization" select="$serialization"/>
77
+ </xsl:apply-templates>
78
+ </xsl:attribute>
79
+ </madsrdf:hasRelatedAuthority>
80
+ </xsl:if>
81
+ </xsl:for-each>
82
+ <xsl:apply-templates select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and not(contains(text(),'://'))]" mode="subfield0orw">
83
+ <xsl:with-param name="serialization" select="$serialization"/>
84
+ </xsl:apply-templates>
85
+ </bf:ClassificationLcc>
86
+ </bf:classification>
87
+ </xsl:for-each>
88
+ </xsl:when>
89
+ </xsl:choose>
90
+ </xsl:template>
91
+
92
+ <xsl:template match="marc:datafield[(@tag='052' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='052')) and @ind1=' ']" mode="work">
93
+ <xsl:param name="serialization" select="'rdfxml'"/>
94
+ <xsl:choose>
95
+ <xsl:when test="marc:subfield[@code='b']">
96
+ <xsl:for-each select="marc:subfield[@code='b']">
97
+ <xsl:variable name="vUri">
98
+ <xsl:value-of select="concat($classG,../marc:subfield[@code='a'],'.',.)"/>
99
+ </xsl:variable>
100
+ <xsl:choose>
101
+ <xsl:when test="$serialization = 'rdfxml'">
102
+ <bf:geographicCoverage>
103
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="$vUri"/></xsl:attribute>
104
+ </bf:geographicCoverage>
105
+ </xsl:when>
106
+ </xsl:choose>
107
+ </xsl:for-each>
108
+ </xsl:when>
109
+ <xsl:otherwise>
110
+ <xsl:choose>
111
+ <xsl:when test="$serialization = 'rdfxml'">
112
+ <xsl:for-each select="marc:subfield[@code='a']">
113
+ <bf:geographicCoverage>
114
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($classG,.)"/></xsl:attribute>
115
+ </bf:geographicCoverage>
116
+ </xsl:for-each>
117
+ </xsl:when>
118
+ </xsl:choose>
119
+ </xsl:otherwise>
120
+ </xsl:choose>
121
+ </xsl:template>
122
+
123
+ <xsl:template match="marc:datafield" mode="work052">
124
+ <xsl:param name="serialization" select="'rdfxml'"/>
125
+ <xsl:choose>
126
+ <xsl:when test="$serialization='rdfxml'">
127
+ <xsl:for-each select="marc:subfield[@code='d']">
128
+ <bf:place>
129
+ <bf:Place>
130
+ <rdfs:label>
131
+ <xsl:call-template name="tChopPunct">
132
+ <xsl:with-param name="pString" select="."/>
133
+ </xsl:call-template>
134
+ </rdfs:label>
135
+ </bf:Place>
136
+ </bf:place>
137
+ </xsl:for-each>
138
+ <xsl:for-each select="marc:subfield[@code='0' and contains(text(),'://')]">
139
+ <xsl:if test="position() != 1">
140
+ <xsl:apply-templates select="." mode="subfield0orw">
141
+ <xsl:with-param name="serialization" select="$serialization"/>
142
+ </xsl:apply-templates>
143
+ </xsl:if>
144
+ </xsl:for-each>
145
+ <xsl:for-each select="marc:subfield[@code='0' and not(contains(text(),'://'))]">
146
+ <xsl:apply-templates select="." mode="subfield0orw">
147
+ <xsl:with-param name="serialization" select="$serialization"/>
148
+ </xsl:apply-templates>
149
+ </xsl:for-each>
150
+ </xsl:when>
151
+ </xsl:choose>
152
+ </xsl:template>
153
+
154
+ <!--
155
+ To our northern neighbors...
156
+ This MARC field may contain more than LCC numbers (ind2 is 6, 7, 8, or 9) so you may need
157
+ to account for those.
158
+ Also, not being able to identify who assigned an LCC - other than LAC - creates a conflict
159
+ with LCCs converted from the 050 that were not assigned by LC. So non-LAC LCCs are
160
+ ignored at present (sorry!; decisions had to be made); you may need to
161
+ account for those too.
162
+ -->
163
+ <xsl:template match="marc:datafield[
164
+ (@tag='055' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='055')) and
165
+ (@ind2='0' or @ind2='1' or @ind1='2')]" mode="work">
166
+ <xsl:param name="serialization" select="'rdfxml'"/>
167
+ <xsl:variable name="vNodeUri">
168
+ <xsl:for-each select="marc:subfield[@code='0' and contains(text(),'://')][1]">
169
+ <xsl:choose>
170
+ <xsl:when test="starts-with(.,'(uri)')">
171
+ <xsl:value-of select="substring-after(.,'(uri)')"/>
172
+ </xsl:when>
173
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
174
+ </xsl:choose>
175
+ </xsl:for-each>
176
+ </xsl:variable>
177
+ <xsl:choose>
178
+ <xsl:when test="$serialization = 'rdfxml'">
179
+ <bf:classification>
180
+ <bf:ClassificationLcc>
181
+ <!-- If there is a currentNodeUri *and* there is no item portion, we can use a URI, I guess. -->
182
+ <xsl:if test="$vNodeUri != '' and not(marc:subfield[@code='b'])">
183
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vNodeUri"/></xsl:attribute>
184
+ </xsl:if>
185
+ <xsl:for-each select="marc:subfield[@code='a']">
186
+ <bf:classificationPortion>
187
+ <xsl:value-of select="."/>
188
+ </bf:classificationPortion>
189
+ </xsl:for-each>
190
+ <xsl:for-each select="marc:subfield[@code='b']">
191
+ <bf:itemPortion>
192
+ <xsl:value-of select="."/>
193
+ </bf:itemPortion>
194
+ </xsl:for-each>
195
+ <xsl:if test="@ind2 = '0' or @ind2 = '1' or @ind2 = '2'">
196
+ <bf:assigner>
197
+ <xsl:attribute name="rdf:resource">http://id.loc.gov/authorities/names/no2004037399</xsl:attribute>
198
+ </bf:assigner>
199
+ <xsl:choose>
200
+ <xsl:when test="@ind1 = '0'">
201
+ <bf:status>
202
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($mstatus,'uba')"/></xsl:attribute>
203
+ </bf:status>
204
+ </xsl:when>
205
+ <xsl:when test="@ind1 = '1'">
206
+ <bf:status>
207
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($mstatus,'nuba')"/></xsl:attribute>
208
+ </bf:status>
209
+ </xsl:when>
210
+ </xsl:choose>
211
+ </xsl:if>
212
+ <xsl:for-each select="marc:subfield[@code='0' and contains(text(),'://')]">
213
+ <xsl:if test="(position() = 1 and $vNodeUri != '' and ../marc:subfield[@code='b'][position()=1])
214
+ or
215
+ position() != 1">
216
+ <madsrdf:hasRelatedAuthority>
217
+ <xsl:attribute name="rdf:resource">
218
+ <xsl:apply-templates select="." mode="generateUriFrom0">
219
+ <xsl:with-param name="serialization" select="$serialization"/>
220
+ </xsl:apply-templates>
221
+ </xsl:attribute>
222
+ </madsrdf:hasRelatedAuthority>
223
+ </xsl:if>
224
+ </xsl:for-each>
225
+ <xsl:for-each select="marc:subfield[@code='0' and not(contains(text(),'://'))]">
226
+ <xsl:apply-templates select="." mode="subfield0orw">
227
+ <xsl:with-param name="serialization" select="$serialization"/>
228
+ </xsl:apply-templates>
229
+ </xsl:for-each>
230
+ </bf:ClassificationLcc>
231
+ </bf:classification>
232
+ </xsl:when>
233
+ </xsl:choose>
234
+ </xsl:template>
235
+
236
+ <xsl:template match="marc:datafield[@tag='060' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='060')]" mode="work">
237
+ <xsl:param name="serialization" select="'rdfxml'"/>
238
+ <xsl:choose>
239
+ <xsl:when test="$serialization = 'rdfxml'">
240
+ <xsl:for-each select="marc:subfield[@code='a']">
241
+ <xsl:variable name="vCurrentNode" select="generate-id(.)"/>
242
+ <xsl:variable name="vCurrentNodeUri">
243
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
244
+ <xsl:if test="position() = 1">
245
+ <xsl:choose>
246
+ <xsl:when test="starts-with(.,'(uri)')">
247
+ <xsl:value-of select="substring-after(.,'(uri)')"/>
248
+ </xsl:when>
249
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
250
+ </xsl:choose>
251
+ </xsl:if>
252
+ </xsl:for-each>
253
+ </xsl:variable>
254
+ <bf:classification>
255
+ <bf:ClassificationNlm>
256
+ <!-- If there is a currentNodeUri *and* there is no item portion, we can use a URI, I guess. -->
257
+ <xsl:if test="$vCurrentNodeUri != '' and not(../marc:subfield[@code='b'][position()=1])">
258
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vCurrentNodeUri"/></xsl:attribute>
259
+ </xsl:if>
260
+ <bf:classificationPortion><xsl:value-of select="."/></bf:classificationPortion>
261
+ <xsl:if test="position() = 1">
262
+ <xsl:for-each select="../marc:subfield[@code='b']">
263
+ <bf:itemPortion><xsl:value-of select="."/></bf:itemPortion>
264
+ </xsl:for-each>
265
+ </xsl:if>
266
+ <xsl:if test="../@ind2 = '0' or
267
+ (../@ind2 = ' ' and contains(ancestor::marc:record/marc:datafield[@tag='040']/marc:subfield[@code='a'][1], 'NLM'))
268
+ ">
269
+ <bf:assigner>
270
+ <xsl:attribute name="rdf:resource">http://id.loc.gov/vocabulary/organizations/dnlm</xsl:attribute>
271
+ </bf:assigner>
272
+ <xsl:choose>
273
+ <xsl:when test="../@ind1 = '0'">
274
+ <bf:status>
275
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($mstatus,'uba')"/></xsl:attribute>
276
+ </bf:status>
277
+ </xsl:when>
278
+ <xsl:when test="../@ind1 = '1'">
279
+ <bf:status>
280
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($mstatus,'nuba')"/></xsl:attribute>
281
+ </bf:status>
282
+ </xsl:when>
283
+ </xsl:choose>
284
+ </xsl:if>
285
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
286
+ <xsl:if test="(position() = 1 and $vCurrentNodeUri != '' and ../marc:subfield[@code='b'][position()=1])
287
+ or
288
+ position() != 1">
289
+ <madsrdf:hasRelatedAuthority>
290
+ <xsl:attribute name="rdf:resource">
291
+ <xsl:apply-templates select="." mode="generateUriFrom0">
292
+ <xsl:with-param name="serialization" select="$serialization"/>
293
+ </xsl:apply-templates>
294
+ </xsl:attribute>
295
+ </madsrdf:hasRelatedAuthority>
296
+ </xsl:if>
297
+ </xsl:for-each>
298
+ <xsl:apply-templates select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and not(contains(text(),'://'))]" mode="subfield0orw">
299
+ <xsl:with-param name="serialization" select="$serialization"/>
300
+ </xsl:apply-templates>
301
+ </bf:ClassificationNlm>
302
+ </bf:classification>
303
+ </xsl:for-each>
304
+ </xsl:when>
305
+ </xsl:choose>
306
+ </xsl:template>
307
+
308
+ <xsl:template match="marc:datafield[@tag='070' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='070')]" mode="work">
309
+ <xsl:param name="serialization" select="'rdfxml'"/>
310
+ <xsl:choose>
311
+ <xsl:when test="$serialization = 'rdfxml'">
312
+ <xsl:for-each select="marc:subfield[@code='a']">
313
+ <xsl:variable name="vCurrentNode" select="generate-id(.)"/>
314
+ <xsl:variable name="vCurrentNodeUri">
315
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
316
+ <xsl:if test="position() = 1">
317
+ <xsl:choose>
318
+ <xsl:when test="starts-with(.,'(uri)')">
319
+ <xsl:value-of select="substring-after(.,'(uri)')"/>
320
+ </xsl:when>
321
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
322
+ </xsl:choose>
323
+ </xsl:if>
324
+ </xsl:for-each>
325
+ </xsl:variable>
326
+ <bf:classification>
327
+ <bf:ClassificationNal>
328
+ <!-- If there is a currentNodeUri *and* there is no item portion, we can use a URI, I guess. -->
329
+ <xsl:if test="$vCurrentNodeUri != '' and not(../marc:subfield[@code='b'][position()=1])">
330
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vCurrentNodeUri"/></xsl:attribute>
331
+ </xsl:if>
332
+ <xsl:if test="../@ind1='0'">
333
+ <bf:assigner>
334
+ <xsl:attribute name="rdf:resource">http://id.loc.gov/vocabulary/organizations/dnal</xsl:attribute>
335
+ </bf:assigner>
336
+ <bf:status>
337
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($mstatus,'uba')"/></xsl:attribute>
338
+ </bf:status>
339
+ </xsl:if>
340
+ <bf:classificationPortion><xsl:value-of select="."/></bf:classificationPortion>
341
+ <xsl:if test="position() = 1">
342
+ <xsl:for-each select="../marc:subfield[@code='b']">
343
+ <bf:itemPortion><xsl:value-of select="."/></bf:itemPortion>
344
+ </xsl:for-each>
345
+ </xsl:if>
346
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
347
+ <xsl:if test="(position() = 1 and $vCurrentNodeUri != '' and ../marc:subfield[@code='b'][position()=1])
348
+ or
349
+ position() != 1">
350
+ <madsrdf:hasRelatedAuthority>
351
+ <xsl:attribute name="rdf:resource">
352
+ <xsl:apply-templates select="." mode="generateUriFrom0">
353
+ <xsl:with-param name="serialization" select="$serialization"/>
354
+ </xsl:apply-templates>
355
+ </xsl:attribute>
356
+ </madsrdf:hasRelatedAuthority>
357
+ </xsl:if>
358
+ </xsl:for-each>
359
+ <xsl:apply-templates select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and not(contains(text(),'://'))]" mode="subfield0orw">
360
+ <xsl:with-param name="serialization" select="$serialization"/>
361
+ </xsl:apply-templates>
362
+ </bf:ClassificationNal>
363
+ </bf:classification>
364
+ </xsl:for-each>
365
+ </xsl:when>
366
+ </xsl:choose>
367
+ </xsl:template>
368
+
369
+ <xsl:template match="marc:datafield[@tag='072' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='072')]" mode="work">
370
+ <xsl:param name="serialization" select="'rdfxml'"/>
371
+ <xsl:variable name="vSubjectValue">
372
+ <xsl:value-of select="concat(marc:subfield[@code='a'], marc:subfield[@code='x'])" />
373
+ </xsl:variable>
374
+ <xsl:choose>
375
+ <xsl:when test="$serialization = 'rdfxml'">
376
+ <bf:subject>
377
+ <bf:Topic>
378
+ <bf:code><xsl:value-of select="normalize-space($vSubjectValue)"/></bf:code>
379
+ <xsl:choose>
380
+ <xsl:when test="@ind2 = '0'">
381
+ <bf:source>
382
+ <bf:Source>
383
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/classSchemes/agricola</xsl:attribute>
384
+ </bf:Source>
385
+ </bf:source>
386
+ </xsl:when>
387
+ <xsl:otherwise>
388
+ <xsl:for-each select="marc:subfield[@code='2']">
389
+ <xsl:choose>
390
+ <xsl:when test="text()='bisacsh'">
391
+ <bf:source>
392
+ <bf:Source>
393
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/classSchemes/bisacsh</xsl:attribute>
394
+ </bf:Source>
395
+ </bf:source>
396
+ </xsl:when>
397
+ <xsl:otherwise>
398
+ <xsl:apply-templates select="." mode="subfield2">
399
+ <xsl:with-param name="serialization" select="$serialization"/>
400
+ </xsl:apply-templates>
401
+ </xsl:otherwise>
402
+ </xsl:choose>
403
+ </xsl:for-each>
404
+ </xsl:otherwise>
405
+ </xsl:choose>
406
+ </bf:Topic>
407
+ </bf:subject>
408
+ </xsl:when>
409
+ </xsl:choose>
410
+ </xsl:template>
411
+
412
+ <xsl:template match="marc:datafield[@tag='080' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='080')]" mode="work">
413
+ <xsl:param name="serialization" select="'rdfxml'"/>
414
+ <xsl:choose>
415
+ <xsl:when test="$serialization = 'rdfxml'">
416
+ <xsl:for-each select="marc:subfield[@code='a']">
417
+ <bf:classification>
418
+ <bf:ClassificationUdc>
419
+ <bf:classificationPortion>
420
+ <xsl:value-of select="."/>
421
+ </bf:classificationPortion>
422
+ <xsl:if test="../marc:subfield[@code='b']">
423
+ <bf:itemPortion>
424
+ <xsl:value-of select="../marc:subfield[@code='b'][1]"/>
425
+ </bf:itemPortion>
426
+ </xsl:if>
427
+ <xsl:for-each select="../marc:subfield[@code='x']">
428
+ <bf:code>
429
+ <xsl:value-of select="."/>
430
+ </bf:code>
431
+ </xsl:for-each>
432
+ <xsl:apply-templates select="../marc:subfield[@code='2']" mode="subfield2">
433
+ <xsl:with-param name="serialization" select="$serialization"/>
434
+ </xsl:apply-templates>
435
+ <xsl:choose>
436
+ <xsl:when test="parent::marc:datafield/@ind1 = '0'"><bf:edition>full</bf:edition></xsl:when>
437
+ <xsl:when test="parent::marc:datafield/@ind1 = '1'"><bf:edition>abridged</bf:edition></xsl:when>
438
+ </xsl:choose>
439
+ <xsl:for-each select="../marc:subfield[@code='0' and contains(text(),'://')]">
440
+ <madsrdf:hasRelatedAuthority>
441
+ <xsl:attribute name="rdf:resource">
442
+ <xsl:apply-templates select="." mode="generateUriFrom0">
443
+ <xsl:with-param name="serialization" select="$serialization"/>
444
+ </xsl:apply-templates>
445
+ </xsl:attribute>
446
+ </madsrdf:hasRelatedAuthority>
447
+ </xsl:for-each>
448
+ <xsl:for-each select="../marc:subfield[@code='0' and not(contains(text(),'://'))]">
449
+ <xsl:apply-templates select="." mode="subfield0orw">
450
+ <xsl:with-param name="serialization" select="$serialization"/>
451
+ </xsl:apply-templates>
452
+ </xsl:for-each>
453
+ </bf:ClassificationUdc>
454
+ </bf:classification>
455
+ </xsl:for-each>
456
+ </xsl:when>
457
+ </xsl:choose>
458
+ </xsl:template>
459
+
460
+ <xsl:template match="marc:datafield[@tag='082' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='082')]" mode="work">
461
+ <xsl:param name="serialization" select="'rdfxml'"/>
462
+ <xsl:choose>
463
+ <xsl:when test="$serialization = 'rdfxml'">
464
+ <bf:classification>
465
+ <bf:ClassificationDdc>
466
+ <xsl:if test="marc:subfield[@code='1']">
467
+ <xsl:attribute name="rdf:about">
468
+ <xsl:apply-templates select="." mode="generateUriFrom1">
469
+ <xsl:with-param name="serialization" select="$serialization"/>
470
+ </xsl:apply-templates>
471
+ </xsl:attribute>
472
+ </xsl:if>
473
+ <xsl:for-each select="marc:subfield[@code='a']">
474
+ <bf:classificationPortion>
475
+ <xsl:value-of select="."/>
476
+ </bf:classificationPortion>
477
+ <xsl:if test="position() = 1">
478
+ <xsl:for-each select="../marc:subfield[@code='b']">
479
+ <bf:itemPortion>
480
+ <xsl:value-of select="."/>
481
+ </bf:itemPortion>
482
+ </xsl:for-each>
483
+ </xsl:if>
484
+ </xsl:for-each>
485
+ <xsl:for-each select="marc:subfield[@code='q']">
486
+ <bf:assigner>
487
+ <bf:Agent>
488
+ <rdfs:label><xsl:value-of select="."/></rdfs:label>
489
+ </bf:Agent>
490
+ </bf:assigner>
491
+ </xsl:for-each>
492
+ <xsl:apply-templates select="marc:subfield[@code='2']" mode="subfield2">
493
+ <xsl:with-param name="serialization" select="$serialization"/>
494
+ </xsl:apply-templates>
495
+ <xsl:choose>
496
+ <xsl:when test="@ind1 = '0'"><bf:edition>full</bf:edition></xsl:when>
497
+ <xsl:when test="@ind1 = '1'"><bf:edition>abridged</bf:edition></xsl:when>
498
+ </xsl:choose>
499
+ <xsl:choose>
500
+ <xsl:when test="@ind2 = '0'">
501
+ <bf:assigner>
502
+ <bf:Agent>
503
+ <xsl:attribute name="rdf:about"><xsl:value-of select="concat($organizations,'dlc')"/></xsl:attribute>
504
+ </bf:Agent>
505
+ </bf:assigner>
506
+ </xsl:when>
507
+ <xsl:when test="marc:subfield[@code='q']">
508
+ <bf:assigner>
509
+ <bf:Agent>
510
+ <rdfs:label><xsl:value-of select="marc:subfield[@code='q']"/></rdfs:label>
511
+ </bf:Agent>
512
+ </bf:assigner>
513
+ </xsl:when>
514
+ <xsl:when test="@ind2 = ' ' and contains(../marc:datafield[@tag='040']/marc:subfield[@code='a'][1], 'DLC')">
515
+ <bf:assigner>
516
+ <bf:Agent>
517
+ <xsl:attribute name="rdf:about"><xsl:value-of select="concat($organizations,'dlc')"/></xsl:attribute>
518
+ </bf:Agent>
519
+ </bf:assigner>
520
+ </xsl:when>
521
+ </xsl:choose>
522
+ </bf:ClassificationDdc>
523
+ </bf:classification>
524
+ </xsl:when>
525
+ </xsl:choose>
526
+ </xsl:template>
527
+
528
+ <xsl:template match="marc:datafield[@tag='084' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='084')]" mode="work">
529
+ <xsl:param name="serialization" select="'rdfxml'"/>
530
+ <xsl:choose>
531
+ <xsl:when test="$serialization = 'rdfxml'">
532
+ <xsl:for-each select="marc:subfield[@code='a']">
533
+ <xsl:variable name="vCurrentNode" select="generate-id(.)"/>
534
+ <xsl:variable name="vCurrentNodeUri">
535
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
536
+ <xsl:if test="position() = 1">
537
+ <xsl:choose>
538
+ <xsl:when test="starts-with(.,'(uri)')">
539
+ <xsl:value-of select="substring-after(.,'(uri)')"/>
540
+ </xsl:when>
541
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
542
+ </xsl:choose>
543
+ </xsl:if>
544
+ </xsl:for-each>
545
+ </xsl:variable>
546
+ <bf:classification>
547
+ <bf:Classification>
548
+ <!-- If there is a currentNodeUri *and* there is no item portion, we can use a URI, I guess. -->
549
+ <xsl:if test="$vCurrentNodeUri != '' and not(../marc:subfield[@code='b'][position()=1])">
550
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vCurrentNodeUri"/></xsl:attribute>
551
+ </xsl:if>
552
+ <bf:classificationPortion>
553
+ <xsl:value-of select="."/>
554
+ </bf:classificationPortion>
555
+ <xsl:if test="position() = 1">
556
+ <xsl:for-each select="../marc:subfield[@code='b']">
557
+ <bf:itemPortion>
558
+ <xsl:value-of select="."/>
559
+ </bf:itemPortion>
560
+ </xsl:for-each>
561
+ </xsl:if>
562
+ <xsl:for-each select="../marc:subfield[@code='q']">
563
+ <bf:assigner>
564
+ <bf:Agent>
565
+ <rdfs:label><xsl:value-of select="."/></rdfs:label>
566
+ </bf:Agent>
567
+ </bf:assigner>
568
+ </xsl:for-each>
569
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
570
+ <xsl:if test="(position() = 1 and $vCurrentNodeUri != '' and ../marc:subfield[@code='b'][position()=1])
571
+ or
572
+ position() != 1">
573
+ <madsrdf:hasRelatedAuthority>
574
+ <xsl:attribute name="rdf:resource">
575
+ <xsl:apply-templates select="." mode="generateUriFrom0">
576
+ <xsl:with-param name="serialization" select="$serialization"/>
577
+ </xsl:apply-templates>
578
+ </xsl:attribute>
579
+ </madsrdf:hasRelatedAuthority>
580
+ </xsl:if>
581
+ </xsl:for-each>
582
+ <xsl:apply-templates select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and not(contains(text(),'://'))]" mode="subfield0orw">
583
+ <xsl:with-param name="serialization" select="$serialization"/>
584
+ </xsl:apply-templates>
585
+ <xsl:apply-templates select="../marc:subfield[@code='2']" mode="subfield2">
586
+ <xsl:with-param name="serialization" select="'rdfxml'"/>
587
+ </xsl:apply-templates>
588
+ </bf:Classification>
589
+ </bf:classification>
590
+ </xsl:for-each>
591
+ </xsl:when>
592
+ </xsl:choose>
593
+ </xsl:template>
594
+
595
+ <!-- instance match for field 074 in ConvSpec-010-048.xsl -->
596
+
597
+ <xsl:template match="marc:datafield[@tag='086' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='086')]" mode="work">
598
+ <xsl:param name="serialization" select="'rdfxml'"/>
599
+ <xsl:choose>
600
+ <xsl:when test="$serialization = 'rdfxml'">
601
+ <xsl:for-each select="marc:subfield[@code='a' or @code='z']">
602
+ <xsl:variable name="vCurrentNode" select="generate-id(.)"/>
603
+ <xsl:variable name="vCurrentNodeUri">
604
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
605
+ <xsl:if test="position() = 1">
606
+ <xsl:choose>
607
+ <xsl:when test="starts-with(.,'(uri)')">
608
+ <xsl:value-of select="substring-after(.,'(uri)')"/>
609
+ </xsl:when>
610
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
611
+ </xsl:choose>
612
+ </xsl:if>
613
+ </xsl:for-each>
614
+ </xsl:variable>
615
+ <bf:classification>
616
+ <bf:Classification>
617
+ <!-- If there is a currentNodeUri *and* there is no item portion, we can use a URI, I guess. -->
618
+ <xsl:if test="$vCurrentNodeUri != '' and not(../marc:subfield[@code='b'][position()=1])">
619
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vCurrentNodeUri"/></xsl:attribute>
620
+ </xsl:if>
621
+ <rdfs:label><xsl:value-of select="."/></rdfs:label>
622
+ <xsl:if test="@code='z'">
623
+ <bf:status>
624
+ <bf:Status>
625
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/mstatus/cancinv</xsl:attribute>
626
+ <rdfs:label>invalid</rdfs:label>
627
+ </bf:Status>
628
+ </bf:status>
629
+ </xsl:if>
630
+ <xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
631
+ <xsl:if test="(position() = 1 and $vCurrentNodeUri != '' and ../marc:subfield[@code='b'][position()=1])
632
+ or
633
+ position() != 1">
634
+ <madsrdf:hasRelatedAuthority>
635
+ <xsl:attribute name="rdf:resource">
636
+ <xsl:apply-templates select="." mode="generateUriFrom0">
637
+ <xsl:with-param name="serialization" select="$serialization"/>
638
+ </xsl:apply-templates>
639
+ </xsl:attribute>
640
+ </madsrdf:hasRelatedAuthority>
641
+ </xsl:if>
642
+ </xsl:for-each>
643
+ <xsl:apply-templates select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and not(contains(text(),'://'))]" mode="subfield0orw">
644
+ <xsl:with-param name="serialization" select="$serialization"/>
645
+ </xsl:apply-templates>
646
+ <xsl:choose>
647
+ <xsl:when test="../@ind1='0'">
648
+ <bf:source>
649
+ <bf:Source>
650
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/classSchemes/sudocs</xsl:attribute>
651
+ </bf:Source>
652
+ </bf:source>
653
+ </xsl:when>
654
+ <xsl:when test="../@ind1='1'">
655
+ <bf:source>
656
+ <bf:Source>
657
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/classSchemes/cacodoc</xsl:attribute>
658
+ </bf:Source>
659
+ </bf:source>
660
+ </xsl:when>
661
+ <xsl:otherwise>
662
+ <xsl:for-each select="../marc:subfield[@code='2']">
663
+ <bf:source>
664
+ <bf:Source>
665
+ <bf:code>
666
+ <xsl:value-of select="."/>
667
+ </bf:code>
668
+ </bf:Source>
669
+ </bf:source>
670
+ </xsl:for-each>
671
+ </xsl:otherwise>
672
+ </xsl:choose>
673
+ </bf:Classification>
674
+ </bf:classification>
675
+ </xsl:for-each>
676
+ </xsl:when>
677
+ </xsl:choose>
678
+ </xsl:template>
679
+
680
+ <!-- instance match for fields 074, 088 in ConvSpec-010-048.xsl -->
681
+
682
+ <xsl:template match="marc:datafield[@tag='051']" mode="item">
683
+ <xsl:param name="recordid"/>
684
+ <xsl:param name="serialization" select="'rdfxml'"/>
685
+ <xsl:choose>
686
+ <xsl:when test="$serialization = 'rdfxml'">
687
+ <bf:classification>
688
+ <bf:ClassificationLcc>
689
+ <bf:classificationPortion>
690
+ <xsl:value-of select="marc:subfield[@code='a']"/>
691
+ </bf:classificationPortion>
692
+ <xsl:if test="marc:subfield[@code='b']">
693
+ <bf:itemPortion>
694
+ <xsl:value-of select="marc:subfield[@code='b']"/>
695
+ </bf:itemPortion>
696
+ </xsl:if>
697
+ <xsl:if test="marc:subfield[@code='c']">
698
+ <bf:note>
699
+ <bf:Note>
700
+ <rdfs:label><xsl:value-of select="marc:subfield[@code='c']"/></rdfs:label>
701
+ </bf:Note>
702
+ </bf:note>
703
+ </xsl:if>
704
+ <bf:assigner>
705
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($organizations,'dlc')"/></xsl:attribute>
706
+ </bf:assigner>
707
+ </bf:ClassificationLcc>
708
+ </bf:classification>
709
+ </xsl:when>
710
+ </xsl:choose>
711
+ </xsl:template>
712
+
713
+ </xsl:stylesheet>