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,183 @@
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 LDR
14
+ -->
15
+
16
+ <!-- determine rdf:type for Instance from LDR -->
17
+ <!--
18
+ At this time - 3 Aug 2022 - the notion of Instance type is close to non-existent,
19
+ at least with respect to default typing for every MARC record. (An Instance can
20
+ still receive typing from the 007.) This is basically a Hub check (is it a Hub?).
21
+ vinstanceType, which tends to be set as a result of this, doesn't appear to be used.
22
+ Point is this: A future refactor could involve rewriting this to be a simple Hub
23
+ check and then not passing vinstanceType all over since it is not really used.
24
+ -->
25
+ <xsl:template match="marc:leader" mode="instanceType">
26
+ <xsl:param name="pBaseUri" />
27
+ <xsl:choose>
28
+ <!--
29
+ <xsl:when test="substring(.,7,1) = 'd'">Manuscript</xsl:when>
30
+ <xsl:when test="substring(.,7,1) = 'f'">Manuscript</xsl:when>
31
+ <xsl:when test="substring(.,7,1) = 'm'">Electronic</xsl:when>
32
+ <xsl:when test="substring(.,7,1) = 't'">Manuscript</xsl:when>
33
+ -->
34
+ <xsl:when test="substring(.,7,1) = 'q'">Hub</xsl:when>
35
+ <!-- <xsl:when test="substring(.,7,1) = 'a' and contains('abims',substring(.,8,1))">Print</xsl:when> -->
36
+ <xsl:when test="../marc:datafield[
37
+ @tag='958' and
38
+ marc:subfield[@code='a']='SplitMARC']">SecondaryInstance</xsl:when>
39
+ <xsl:when test="../marc:datafield[
40
+ @tag='758' and
41
+ marc:subfield[@code='4']='http://id.loc.gov/ontologies/bibframe/instanceOf' and
42
+ contains(marc:subfield[@code='1'], $pBaseUri)
43
+ ]">SecondaryInstance</xsl:when>
44
+ </xsl:choose>
45
+ </xsl:template>
46
+
47
+ <xsl:template match="marc:leader" mode="adminmetadata">
48
+ <xsl:param name="serialization" select="'rdfxml'"/>
49
+ <!--
50
+ <xsl:variable name="vStatus" select="substring(.,6,1)"/>
51
+ <xsl:for-each select="$codeMaps/maps/mstatus/*[name() = $vStatus]">
52
+ <xsl:choose>
53
+ <xsl:when test="$serialization = 'rdfxml'">
54
+ <bf:status>
55
+ <bf:Status>
56
+ <xsl:attribute name="rdf:about"><xsl:value-of select="@href"/></xsl:attribute>
57
+ <rdfs:label><xsl:value-of select="."/></rdfs:label>
58
+ </bf:Status>
59
+ </bf:status>
60
+ </xsl:when>
61
+ </xsl:choose>
62
+ </xsl:for-each>
63
+ -->
64
+ <xsl:variable name="vEncLvl" select="concat('_',translate(substring(.,18,1),' ','0'))"/>
65
+ <xsl:for-each select="$codeMaps/maps/menclvl/*[name() = $vEncLvl]">
66
+ <xsl:choose>
67
+ <xsl:when test="$serialization = 'rdfxml'">
68
+ <bflc:encodingLevel>
69
+ <bflc:EncodingLevel>
70
+ <xsl:attribute name="rdf:about"><xsl:value-of select="@href"/></xsl:attribute>
71
+ <rdfs:label><xsl:value-of select="."/></rdfs:label>
72
+ </bflc:EncodingLevel>
73
+ </bflc:encodingLevel>
74
+ </xsl:when>
75
+ </xsl:choose>
76
+ </xsl:for-each>
77
+ <xsl:variable name="vDescriptionConvention" select="translate(substring(.,19,1),' ','_')"/>
78
+ <xsl:if test="not(../marc:datafield[@tag='040']/marc:subfield[@code='e']) or
79
+ ../marc:datafield[@tag='040']/marc:subfield[@code='e']!='rda' or
80
+ (
81
+ ../marc:datafield[@tag='040']/marc:subfield[@code='e']='rda' and
82
+ not(contains('apr', $vDescriptionConvention))
83
+ )">
84
+ <xsl:for-each select="$codeMaps/maps/descriptionConventions/*[name() = $vDescriptionConvention]">
85
+ <xsl:choose>
86
+ <xsl:when test="$serialization = 'rdfxml'">
87
+ <bf:descriptionConventions>
88
+ <bf:DescriptionConventions>
89
+ <xsl:attribute name="rdf:about"><xsl:value-of select="@href"/></xsl:attribute>
90
+ <bf:code><xsl:value-of select="."/></bf:code>
91
+ </bf:DescriptionConventions>
92
+ </bf:descriptionConventions>
93
+ </xsl:when>
94
+ </xsl:choose>
95
+ </xsl:for-each>
96
+ </xsl:if>
97
+ </xsl:template>
98
+
99
+ <xsl:template match="marc:leader" mode="work">
100
+ <xsl:param name="serialization" select="'rdfxml'"/>
101
+ <xsl:variable name="vContentType" select="substring(.,7,1)"/>
102
+ <xsl:variable name="vcMap" select="$codeMaps/maps/contentTypes/*[name() = $vContentType]" />
103
+ <xsl:for-each select="$vcMap">
104
+ <xsl:choose>
105
+ <xsl:when test="$serialization = 'rdfxml'">
106
+ <rdf:type>
107
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($bf,@class)"/></xsl:attribute>
108
+ </rdf:type>
109
+ </xsl:when>
110
+ </xsl:choose>
111
+ </xsl:for-each>
112
+ <xsl:if test="not(../marc:datafield[@tag='336']) and not($vContentType='q')">
113
+ <xsl:for-each select="$vcMap">
114
+ <xsl:if test="@href">
115
+ <bf:content>
116
+ <bf:Content>
117
+ <xsl:attribute name="rdf:about"><xsl:value-of select="@href"/></xsl:attribute>
118
+ <rdfs:label><xsl:value-of select="."/></rdfs:label>
119
+ </bf:Content>
120
+ </bf:content>
121
+ </xsl:if>
122
+ </xsl:for-each>
123
+ </xsl:if>
124
+ <xsl:variable name="vleader07Type">
125
+ <xsl:choose>
126
+ <xsl:when test="substring(.,8,1) = 'a'">Monograph</xsl:when>
127
+ <xsl:when test="substring(.,8,1) = 'b'">Serial</xsl:when>
128
+ <xsl:when test="substring(.,8,1) = 'c'">Collection</xsl:when>
129
+ <xsl:when test="substring(.,8,1) = 'd'">Collection</xsl:when>
130
+ <xsl:when test="substring(.,8,1) = 'm'">Monograph</xsl:when>
131
+ <xsl:when test="substring(.,8,1) = 'i'">Integrating</xsl:when>
132
+ <xsl:when test="substring(.,8,1) = 's'">Serial</xsl:when>
133
+ </xsl:choose>
134
+ </xsl:variable>
135
+ <xsl:if test="$vleader07Type != ''">
136
+ <rdf:type>
137
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($bf, $vleader07Type)"/></xsl:attribute>
138
+ </rdf:type>
139
+ </xsl:if>
140
+ </xsl:template>
141
+
142
+ <xsl:template match="marc:leader" mode="instance">
143
+ <xsl:param name="serialization" select="'rdfxml'"/>
144
+ <xsl:param name="pInstanceType"/>
145
+ <xsl:variable name="issuanceUri">
146
+ <xsl:choose>
147
+ <xsl:when test="substring(.,8,1) = 'a'"><xsl:value-of select="concat($issuance,'mono')"/></xsl:when>
148
+ <xsl:when test="substring(.,8,1) = 'b'"><xsl:value-of select="concat($issuance,'serl')"/></xsl:when>
149
+ <xsl:when test="substring(.,8,1) = 'c'"><xsl:value-of select="concat($issuance,'mulm')"/></xsl:when>
150
+ <xsl:when test="substring(.,8,1) = 'd'"><xsl:value-of select="concat($issuance,'mono')"/></xsl:when>
151
+ <xsl:when test="substring(.,8,1) = 'i'"><xsl:value-of select="concat($issuance,'intg')"/></xsl:when>
152
+ <xsl:when test="substring(.,8,1) = 'm'"><xsl:value-of select="concat($issuance,'mono')"/></xsl:when>
153
+ <xsl:when test="substring(.,8,1) = 's'"><xsl:value-of select="concat($issuance,'serl')"/></xsl:when>
154
+ </xsl:choose>
155
+ </xsl:variable>
156
+ <xsl:choose>
157
+ <xsl:when test="$serialization = 'rdfxml'">
158
+ <!-- setting rdf:type for Hub is redundant here, already set in Work template -->
159
+ <xsl:if test="$pInstanceType != '' and $pInstanceType != 'Hub'">
160
+ <xsl:choose>
161
+ <xsl:when test="$pInstanceType = 'SecondaryInstance'">
162
+ <rdf:type>
163
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($bflc,$pInstanceType)"/></xsl:attribute>
164
+ </rdf:type>
165
+ </xsl:when>
166
+ <xsl:otherwise>
167
+ <rdf:type>
168
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($bf,$pInstanceType)"/></xsl:attribute>
169
+ </rdf:type>
170
+ </xsl:otherwise>
171
+ </xsl:choose>
172
+ </xsl:if>
173
+ <!-- Output an issuance type based on Leader/07 if there is no 334 present in record. -->
174
+ <xsl:if test="$issuanceUri != '' and not (../marc:datafield[@tag = '334'])">
175
+ <bf:issuance>
176
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="$issuanceUri"/></xsl:attribute>
177
+ </bf:issuance>
178
+ </xsl:if>
179
+ </xsl:when>
180
+ </xsl:choose>
181
+ </xsl:template>
182
+
183
+ </xsl:stylesheet>