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,1712 @@
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:local="local:"
10
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11
+ exclude-result-prefixes="xsl marc local">
12
+
13
+ <!--
14
+ Conversion specs for 010-048
15
+ -->
16
+
17
+ <!-- Lookup tables -->
18
+ <local:marctimeperiod>
19
+ <a0>-XXXX/-3000</a0>
20
+ <b0>-29XX</b0>
21
+ <b1>-28XX</b1>
22
+ <b2>-27XX</b2>
23
+ <b3>-26XX</b3>
24
+ <b4>-25XX</b4>
25
+ <b5>-24XX</b5>
26
+ <b6>-23XX</b6>
27
+ <b7>-22XX</b7>
28
+ <b8>-21XX</b8>
29
+ <b9>-20XX</b9>
30
+ <c0>-19XX</c0>
31
+ <c1>-18XX</c1>
32
+ <c2>-17XX</c2>
33
+ <c3>-16XX</c3>
34
+ <c4>-15XX</c4>
35
+ <c5>-14XX</c5>
36
+ <c6>-13XX</c6>
37
+ <c7>-12XX</c7>
38
+ <c8>-11XX</c8>
39
+ <c9>-10XX</c9>
40
+ <d0>-09XX</d0>
41
+ <d1>-08XX</d1>
42
+ <d2>-07XX</d2>
43
+ <d3>-06XX</d3>
44
+ <d4>-05XX</d4>
45
+ <d5>-04XX</d5>
46
+ <d6>-03XX</d6>
47
+ <d7>-02XX</d7>
48
+ <d8>-01XX</d8>
49
+ <d9>-00XX</d9>
50
+ <e>00</e>
51
+ <f>01</f>
52
+ <g>02</g>
53
+ <h>03</h>
54
+ <i>04</i>
55
+ <j>05</j>
56
+ <k>06</k>
57
+ <l>07</l>
58
+ <m>08</m>
59
+ <n>09</n>
60
+ <o>10</o>
61
+ <p>11</p>
62
+ <q>12</q>
63
+ <r>13</r>
64
+ <s>14</s>
65
+ <t>15</t>
66
+ <u>16</u>
67
+ <v>17</v>
68
+ <w>18</w>
69
+ <x>19</x>
70
+ <y>20</y>
71
+ </local:marctimeperiod>
72
+
73
+ <local:instrumentCode>
74
+ <ba property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType><rdfs:label>horn</rdfs:label></ba>
75
+ <bb property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType><rdfs:label>trumpet</rdfs:label></bb>
76
+ <bc property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType><rdfs:label>coronet</rdfs:label></bc>
77
+ <bd property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType><rdfs:label>trombone</rdfs:label></bd>
78
+ <be property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType><rdfs:label>tuba</rdfs:label></be>
79
+ <bf property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType><rdfs:label>baritone</rdfs:label></bf>
80
+ <bn property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType></bn>
81
+ <bu property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType></bu>
82
+ <by property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass, ethnic</bf:instrumentalType></by>
83
+ <bz property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>brass</bf:instrumentalType></bz>
84
+ <ea property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>electronic</bf:instrumentalType><rdfs:label>electronic synthesizer</rdfs:label></ea>
85
+ <eb property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>electronic</bf:instrumentalType><rdfs:label>electronic tape</rdfs:label></eb>
86
+ <ec property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>electronic</bf:instrumentalType><rdfs:label>computer</rdfs:label></ec>
87
+ <ed property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>electronic</bf:instrumentalType><rdfs:label>ondes martinot</rdfs:label></ed>
88
+ <en property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>electronic</bf:instrumentalType></en>
89
+ <eu property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>electronic</bf:instrumentalType></eu>
90
+ <ez property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>electronic</bf:instrumentalType></ez>
91
+ <ka property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType><rdfs:label>piano</rdfs:label></ka>
92
+ <kb property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType><rdfs:label>organ</rdfs:label></kb>
93
+ <kc property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType><rdfs:label>harpsichord</rdfs:label></kc>
94
+ <kd property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType><rdfs:label>clavichord</rdfs:label></kd>
95
+ <ke property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType><rdfs:label>continuo</rdfs:label></ke>
96
+ <kf property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType><rdfs:label>celeste</rdfs:label></kf>
97
+ <kn property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType></kn>
98
+ <ku property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType></ku>
99
+ <ky property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard, ethnic</bf:instrumentalType></ky>
100
+ <kz property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>keyboard</bf:instrumentalType></kz>
101
+ <pa property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion</bf:instrumentalType><rdfs:label>timpani</rdfs:label></pa>
102
+ <pb property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion</bf:instrumentalType><rdfs:label>xylophone</rdfs:label></pb>
103
+ <pc property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion</bf:instrumentalType><rdfs:label>marimba</rdfs:label></pc>
104
+ <pd property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion</bf:instrumentalType><rdfs:label>drum</rdfs:label></pd>
105
+ <pn property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion</bf:instrumentalType></pn>
106
+ <pu property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion</bf:instrumentalType></pu>
107
+ <py property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion, ethnic</bf:instrumentalType></py>
108
+ <pz property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>percussion</bf:instrumentalType></pz>
109
+ <sa property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType><rdfs:label>violin</rdfs:label></sa>
110
+ <sb property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType><rdfs:label>viola</rdfs:label></sb>
111
+ <sc property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType><rdfs:label>violoncello</rdfs:label></sc>
112
+ <sd property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType><rdfs:label>double bass</rdfs:label></sd>
113
+ <se property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType><rdfs:label>viol</rdfs:label></se>
114
+ <sf property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType><rdfs:label>viola d'amore</rdfs:label></sf>
115
+ <sg property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType><rdfs:label>viola da gamba</rdfs:label></sg>
116
+ <sn property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType></sn>
117
+ <su property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType></su>
118
+ <sy property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed, ethnic</bf:instrumentalType></sy>
119
+ <sz property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, bowed</bf:instrumentalType></sz>
120
+ <ta property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked</bf:instrumentalType><rdfs:label>harp</rdfs:label></ta>
121
+ <tb property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked</bf:instrumentalType><rdfs:label>guitar</rdfs:label></tb>
122
+ <tc property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked</bf:instrumentalType><rdfs:label>lute</rdfs:label></tc>
123
+ <td property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked</bf:instrumentalType><rdfs:label>mandolin</rdfs:label></td>
124
+ <tn property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked</bf:instrumentalType></tn>
125
+ <tu property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked</bf:instrumentalType></tu>
126
+ <ty property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked, ethnic</bf:instrumentalType></ty>
127
+ <tz property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>string, plucked</bf:instrumentalType></tz>
128
+ <wa property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>flute</rdfs:label></wa>
129
+ <wb property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>oboe</rdfs:label></wb>
130
+ <wc property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>clarinet</rdfs:label></wc>
131
+ <wd property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>bassoon</rdfs:label></wd>
132
+ <we property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>piccolo</rdfs:label></we>
133
+ <wf property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>English horn</rdfs:label></wf>
134
+ <wg property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>bass clarinet</rdfs:label></wg>
135
+ <wh property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>recorder</rdfs:label></wh>
136
+ <wi property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType><rdfs:label>saxophone</rdfs:label></wi>
137
+ <wn property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType></wn>
138
+ <wu property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType></wu>
139
+ <wy property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind, ethnic</bf:instrumentalType></wy>
140
+ <wz property="bf:instrument" entity="bf:MusicInstrument"><bf:instrumentalType>woodwind</bf:instrumentalType></wz>
141
+ <oa property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType><rdfs:label>orchestra</rdfs:label></oa>
142
+ <ob property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType><rdfs:label>chamber orchestra</rdfs:label></ob>
143
+ <oc property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType><rdfs:label>string orchestra</rdfs:label></oc>
144
+ <od property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType><rdfs:label>band</rdfs:label></od>
145
+ <oe property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType><rdfs:label>dance orchestra</rdfs:label></oe>
146
+ <of property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType><rdfs:label>brass band</rdfs:label></of>
147
+ <on property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType></on>
148
+ <oo property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType></oo>
149
+ <ou property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType></ou>
150
+ <oy property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental, ethnic</bf:ensembleType></oy>
151
+ <oz property="bf:ensemble" entity="bf:MusicEnsemble"><bf:ensembleType>instrumental</bf:ensembleType></oz>
152
+ <ca property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus</bf:voiceType><rdfs:label>mixed chorus</rdfs:label></ca>
153
+ <cb property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus</bf:voiceType><rdfs:label>female chorus</rdfs:label></cb>
154
+ <cc property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus</bf:voiceType><rdfs:label>male chorus</rdfs:label></cc>
155
+ <cd property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus</bf:voiceType><rdfs:label>children chorus</rdfs:label></cd>
156
+ <cn property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus</bf:voiceType></cn>
157
+ <cu property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus</bf:voiceType></cu>
158
+ <cy property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus, ethnic</bf:voiceType></cy>
159
+ <cz property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>chorus</bf:voiceType></cz>
160
+ <va property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>soprano</rdfs:label></va>
161
+ <vb property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>mezzo soprano</rdfs:label></vb>
162
+ <vc property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>alto</rdfs:label></vc>
163
+ <vd property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>tenor</rdfs:label></vd>
164
+ <ve property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>baritone</rdfs:label></ve>
165
+ <vf property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>bass</rdfs:label></vf>
166
+ <vg property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>counter tenor</rdfs:label></vg>
167
+ <vh property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>high voice</rdfs:label></vh>
168
+ <vi property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>medium voice</rdfs:label></vi>
169
+ <vj property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType><rdfs:label>low voice</rdfs:label></vj>
170
+ <vn property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType></vn>
171
+ <vo property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType></vo>
172
+ <vu property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice</bf:voiceType></vu>
173
+ <vy property="bf:voice" entity="bf:MusicVoice"><bf:voiceType>voice, ethnic</bf:voiceType></vy>
174
+ </local:instrumentCode>
175
+
176
+ <!--
177
+ <xsl:template match="marc:datafield[@tag='016' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='016')]" mode="adminmetadata">
178
+ <xsl:param name="serialization" select="'rdfxml'"/>
179
+ <xsl:choose>
180
+ <xsl:when test="$serialization = 'rdfxml'">
181
+ <xsl:apply-templates select="." mode="instanceId">
182
+ <xsl:with-param name="serialization" select="$serialization"/>
183
+ <xsl:with-param name="pIdentifier">bf:Local</xsl:with-param>
184
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
185
+ </xsl:apply-templates>
186
+ </xsl:when>
187
+ </xsl:choose>
188
+ </xsl:template>
189
+ -->
190
+
191
+ <xsl:template match="marc:datafield[@tag='038' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='038')]" mode="adminmetadata">
192
+ <xsl:param name="serialization" select="'rdfxml'"/>
193
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
194
+ <xsl:choose>
195
+ <xsl:when test="$serialization = 'rdfxml'">
196
+ <xsl:for-each select="marc:subfield[@code='a']">
197
+ <bflc:metadataLicensor>
198
+ <bflc:MetadataLicensor>
199
+ <rdfs:label>
200
+ <xsl:if test="$vXmlLang != ''">
201
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
202
+ </xsl:if>
203
+ <xsl:value-of select="."/>
204
+ </rdfs:label>
205
+ </bflc:MetadataLicensor>
206
+ </bflc:metadataLicensor>
207
+ </xsl:for-each>
208
+ </xsl:when>
209
+ </xsl:choose>
210
+ </xsl:template>
211
+
212
+ <xsl:template match="marc:datafield[@tag='040' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='040')]" mode="adminmetadata">
213
+ <xsl:param name="serialization" select="'rdfxml'"/>
214
+ <xsl:choose>
215
+ <xsl:when test="$serialization = 'rdfxml'">
216
+ <!--
217
+ <xsl:for-each select="marc:subfield[@code='a']">
218
+ <xsl:variable name="vUri">
219
+ <xsl:if test="text() = 'DLC'">
220
+ <xsl:value-of select="concat($organizations,'dlc')"/>
221
+ </xsl:if>
222
+ </xsl:variable>
223
+ <bf:assigner>
224
+ <bf:Agent>
225
+ <xsl:if test="$vUri != ''">
226
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vUri"/></xsl:attribute>
227
+ </xsl:if>
228
+ <bf:code><xsl:value-of select="."/></bf:code>
229
+ </bf:Agent>
230
+ </bf:assigner>
231
+ </xsl:for-each>
232
+ -->
233
+ <xsl:for-each select="marc:subfield[@code='b']">
234
+ <!-- this should be a code -->
235
+ <!-- assume MARC code if 3 characters -->
236
+ <bf:descriptionLanguage>
237
+ <bf:Language>
238
+ <xsl:choose>
239
+ <xsl:when test="string-length(.) = 3">
240
+ <xsl:variable name="encoded">
241
+ <xsl:call-template name="url-encode">
242
+ <xsl:with-param name="str" select="normalize-space(.)"/>
243
+ </xsl:call-template>
244
+ </xsl:variable>
245
+ <xsl:attribute name="rdf:about"><xsl:value-of select="concat($languages,$encoded)"/></xsl:attribute>
246
+ </xsl:when>
247
+ <xsl:otherwise>
248
+ <bf:code><xsl:value-of select="."/></bf:code>
249
+ </xsl:otherwise>
250
+ </xsl:choose>
251
+ </bf:Language>
252
+ </bf:descriptionLanguage>
253
+ </xsl:for-each>
254
+ <!--
255
+ <xsl:for-each select="marc:subfield[@code='d']">
256
+ <xsl:if test="position() = count(../marc:subfield[@code='d'])">
257
+ <bf:descriptionModifier>
258
+ <bf:Agent>
259
+ <xsl:variable name="vUri">
260
+ <xsl:if test="text() = 'DLC'">
261
+ <xsl:value-of select="concat($organizations,'dlc')"/>
262
+ </xsl:if>
263
+ </xsl:variable>
264
+ <xsl:if test="$vUri != ''">
265
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$vUri"/></xsl:attribute>
266
+ </xsl:if>
267
+ <bf:code><xsl:value-of select="."/></bf:code>
268
+ </bf:Agent>
269
+ </bf:descriptionModifier>
270
+ </xsl:if>
271
+ </xsl:for-each>
272
+ -->
273
+ <xsl:for-each select="marc:subfield[@code='e']">
274
+ <bf:descriptionConventions>
275
+ <bf:DescriptionConventions>
276
+ <xsl:if test="not(contains(normalize-space(.),' '))">
277
+ <xsl:variable name="vUri">
278
+ <xsl:call-template name="url-encode">
279
+ <xsl:with-param name="str" select="normalize-space(.)"/>
280
+ </xsl:call-template>
281
+ </xsl:variable>
282
+ <xsl:attribute name="rdf:about"><xsl:value-of select="concat($descriptionConventions,$vUri)"/></xsl:attribute>
283
+ </xsl:if>
284
+ <bf:code><xsl:value-of select="."/></bf:code>
285
+ </bf:DescriptionConventions>
286
+ </bf:descriptionConventions>
287
+ </xsl:for-each>
288
+ <bf:note>
289
+ <bf:Note>
290
+ <rdf:type rdf:resource="http://id.loc.gov/vocabulary/mnotetype/internal" />
291
+ <rdfs:label><xsl:apply-templates select="." mode="marcKey"/></rdfs:label>
292
+ </bf:Note>
293
+ </bf:note>
294
+ </xsl:when>
295
+ </xsl:choose>
296
+ </xsl:template>
297
+
298
+ <xsl:template match="marc:datafield[@tag='042' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='042')]" mode="adminmetadata">
299
+ <xsl:param name="serialization" select="'rdfxml'"/>
300
+ <xsl:choose>
301
+ <xsl:when test="$serialization = 'rdfxml'">
302
+ <xsl:for-each select="marc:subfield[@code='a']">
303
+ <xsl:variable name="encoded">
304
+ <xsl:call-template name="url-encode">
305
+ <xsl:with-param name="str" select="normalize-space(.)"/>
306
+ </xsl:call-template>
307
+ </xsl:variable>
308
+ <bf:descriptionAuthentication>
309
+ <bf:DescriptionAuthentication>
310
+ <xsl:attribute name="rdf:about"><xsl:value-of select="concat($marcauthen,$encoded)"/></xsl:attribute>
311
+ <bf:code><xsl:value-of select="."/></bf:code>
312
+ </bf:DescriptionAuthentication>
313
+ </bf:descriptionAuthentication>
314
+ </xsl:for-each>
315
+ </xsl:when>
316
+ </xsl:choose>
317
+ </xsl:template>
318
+
319
+ <xsl:template match="marc:datafield[@tag='022' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='022')]" mode="work">
320
+ <xsl:param name="serialization" select="'rdfxml'"/>
321
+ <xsl:variable name="vUri">
322
+ <xsl:if test="contains(marc:subfield[@code='0'],'://')">
323
+ <xsl:variable name="vSource" select="substring(substring-after(marc:subfield[@code='0'],'('),1,string-length(substring-before(marc:subfield[@code='0'],')'))-1)"/>
324
+ <xsl:choose>
325
+ <xsl:when test="$vSource != ''"><xsl:value-of select="translate(substring-after(marc:subfield[@code='0'],')'), ' ', '')"/></xsl:when>
326
+ <xsl:otherwise><xsl:value-of select="translate(marc:subfield[@code='0'], ' ', '')"/></xsl:otherwise>
327
+ </xsl:choose>
328
+ </xsl:if>
329
+ </xsl:variable>
330
+ <xsl:apply-templates select="." mode="instanceId">
331
+ <xsl:with-param name="serialization" select="$serialization"/>
332
+ <xsl:with-param name="pIdentifier">bf:Issn</xsl:with-param>
333
+ <xsl:with-param name="pIncorrectLabel">incorrect</xsl:with-param>
334
+ <xsl:with-param name="pInvalidLabel">canceled</xsl:with-param>
335
+ <xsl:with-param name="pUri" select="$vUri"/>
336
+ </xsl:apply-templates>
337
+ <xsl:for-each select="marc:subfield[@code='l'] | marc:subfield[@code='m']">
338
+ <xsl:choose>
339
+ <xsl:when test="$serialization = 'rdfxml'">
340
+ <bf:identifiedBy>
341
+ <bf:IssnL>
342
+ <rdf:value><xsl:value-of select="."/></rdf:value>
343
+ <xsl:if test="@code = 'm'">
344
+ <bf:status>
345
+ <bf:Status>
346
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/mstatus/cancinv</xsl:attribute>
347
+ <rdfs:label>canceled</rdfs:label>
348
+ </bf:Status>
349
+ </bf:status>
350
+ </xsl:if>
351
+ <xsl:for-each select="../marc:subfield[@code='2']">
352
+ <bf:assigner>
353
+ <bf:Agent>
354
+ <bf:code><xsl:value-of select="."/></bf:code>
355
+ </bf:Agent>
356
+ </bf:assigner>
357
+ </xsl:for-each>
358
+ </bf:IssnL>
359
+ </bf:identifiedBy>
360
+ </xsl:when>
361
+ </xsl:choose>
362
+ </xsl:for-each>
363
+ </xsl:template>
364
+
365
+ <xsl:template match="marc:datafield[@tag='023' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='023')]" mode="work">
366
+ <xsl:param name="serialization" select="'rdfxml'"/>
367
+ <xsl:variable name="vIdentifier">
368
+ <xsl:choose>
369
+ <xsl:when test="@ind1='0'">bf:IssnL</xsl:when>
370
+ </xsl:choose>
371
+ </xsl:variable>
372
+ <xsl:variable name="vUri">
373
+ <xsl:if test="contains(marc:subfield[@code='0'],'://')">
374
+ <xsl:variable name="vSource" select="substring(substring-after(marc:subfield[@code='0'],'('),1,string-length(substring-before(marc:subfield[@code='0'],')'))-1)"/>
375
+ <xsl:choose>
376
+ <xsl:when test="$vSource != ''"><xsl:value-of select="substring-after(marc:subfield[@code='0'],')')"/></xsl:when>
377
+ <xsl:otherwise><xsl:value-of select="marc:subfield[@code='0']"/></xsl:otherwise>
378
+ </xsl:choose>
379
+ </xsl:if>
380
+ </xsl:variable>
381
+ <xsl:if test="$vIdentifier!=''">
382
+ <xsl:apply-templates select="." mode="instanceId">
383
+ <xsl:with-param name="serialization" select="$serialization"/>
384
+ <xsl:with-param name="pIdentifier" select="$vIdentifier" />
385
+ <xsl:with-param name="pIncorrectLabel">incorrect</xsl:with-param>
386
+ <xsl:with-param name="pInvalidLabel">canceled</xsl:with-param>
387
+ <xsl:with-param name="pUri" select="$vUri"/>
388
+ </xsl:apply-templates>
389
+ </xsl:if>
390
+ </xsl:template>
391
+
392
+ <xsl:template match="marc:datafield[@tag='024' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='024')]" mode="work">
393
+ <xsl:param name="serialization" select="'rdfxml'"/>
394
+ <xsl:if test="@ind1='7' and marc:subfield[@code='2' and text()='eidr']">
395
+ <xsl:apply-templates select="." mode="instanceId">
396
+ <xsl:with-param name="serialization" select="$serialization"/>
397
+ <xsl:with-param name="pIdentifier">bf:Eidr</xsl:with-param>
398
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
399
+ <xsl:with-param name="pChopPunct" select="true()"/>
400
+ </xsl:apply-templates>
401
+ </xsl:if>
402
+ </xsl:template>
403
+
404
+ <xsl:template match="marc:datafield[@tag='033' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='033')]" mode="work">
405
+ <xsl:param name="serialization" select="'rdfxml'"/>
406
+ <xsl:variable name="vDate">
407
+ <xsl:choose>
408
+ <xsl:when test="@ind1 = '0'">
409
+ <xsl:call-template name="edtfFormat">
410
+ <xsl:with-param name="pDateString" select="marc:subfield[@code='a']"/>
411
+ </xsl:call-template>
412
+ </xsl:when>
413
+ <xsl:when test="@ind1 = '2'">
414
+ <xsl:variable name="vConcatDate">
415
+ <xsl:for-each select="marc:subfield[@code='a']">
416
+ <xsl:variable name="vFormattedDate">
417
+ <xsl:call-template name="edtfFormat">
418
+ <xsl:with-param name="pDateString" select="."/>
419
+ </xsl:call-template>
420
+ </xsl:variable>
421
+ <xsl:value-of select="concat('/',$vFormattedDate)"/>
422
+ </xsl:for-each>
423
+ </xsl:variable>
424
+ <xsl:value-of select="substring-after($vConcatDate,'/')"/>
425
+ </xsl:when>
426
+ </xsl:choose>
427
+ </xsl:variable>
428
+ <xsl:variable name="vNote">
429
+ <xsl:choose>
430
+ <xsl:when test="@ind2 = '0'">capture</xsl:when>
431
+ <xsl:when test="@ind2 = '1'">broadcast</xsl:when>
432
+ <xsl:when test="@ind2 = '2'">finding</xsl:when>
433
+ </xsl:choose>
434
+ </xsl:variable>
435
+ <xsl:choose>
436
+ <xsl:when test="$serialization = 'rdfxml'">
437
+ <bf:capture>
438
+ <bf:Capture>
439
+ <xsl:if test="$vNote != ''">
440
+ <bf:note>
441
+ <bf:Note>
442
+ <rdfs:label><xsl:value-of select="$vNote"/></rdfs:label>
443
+ </bf:Note>
444
+ </bf:note>
445
+ </xsl:if>
446
+ <xsl:if test="$vDate != ''">
447
+ <bf:date>
448
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="$edtf"/>edtf</xsl:attribute>
449
+ <xsl:value-of select="$vDate"/>
450
+ </bf:date>
451
+ </xsl:if>
452
+ <xsl:if test="@ind1 = '1'">
453
+ <xsl:for-each select="marc:subfield[@code='a']">
454
+ <bf:date>
455
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="$edtf"/>edtf</xsl:attribute>
456
+ <xsl:call-template name="edtfFormat">
457
+ <xsl:with-param name="pDateString" select="."/>
458
+ </xsl:call-template>
459
+ </bf:date>
460
+ </xsl:for-each>
461
+ </xsl:if>
462
+ <xsl:for-each select="marc:subfield[@code='b']">
463
+ <xsl:variable name="vClass">
464
+ <xsl:choose>
465
+ <xsl:when test="following-sibling::*[position()=1][@code='c']">
466
+ <xsl:value-of select="concat(normalize-space(.),'.',normalize-space(following-sibling::*[position()=1][@code='c']))"/>
467
+ </xsl:when>
468
+ <xsl:otherwise><xsl:value-of select="normalize-space(.)"/></xsl:otherwise>
469
+ </xsl:choose>
470
+ </xsl:variable>
471
+ <bf:place>
472
+ <xsl:attribute name="rdf:resource">
473
+ <xsl:value-of select="concat($classG,$vClass)"/>
474
+ </xsl:attribute>
475
+ </bf:place>
476
+ </xsl:for-each>
477
+ <xsl:for-each select="marc:subfield[@code='p']">
478
+ <bf:place>
479
+ <bf:Place>
480
+ <rdfs:label><xsl:value-of select="."/></rdfs:label>
481
+ <xsl:apply-templates mode="subfield2" select="following-sibling::*[position()=1][@code='2']">
482
+ <xsl:with-param name="serialization" select="$serialization"/>
483
+ <xsl:with-param name="pVocabStem" select="$subjectSchemes"/>
484
+ </xsl:apply-templates>
485
+ </bf:Place>
486
+ </bf:place>
487
+ </xsl:for-each>
488
+ <xsl:for-each select="marc:subfield[@code='3']">
489
+ <xsl:apply-templates mode="subfield3" select=".">
490
+ <xsl:with-param name="serialization" select="$serialization"/>
491
+ </xsl:apply-templates>
492
+ </xsl:for-each>
493
+ </bf:Capture>
494
+ </bf:capture>
495
+ </xsl:when>
496
+ </xsl:choose>
497
+ </xsl:template>
498
+
499
+ <xsl:template match="marc:datafield[@tag='034' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='034')]" mode="work">
500
+ <xsl:param name="serialization" select="'rdfxml'"/>
501
+ <xsl:variable name="vCoordinates">
502
+ <xsl:apply-templates select="marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']" mode="concat-nodes-space"/>
503
+ </xsl:variable>
504
+ <xsl:choose>
505
+ <xsl:when test="$serialization = 'rdfxml'">
506
+ <xsl:if test="$vCoordinates != ''">
507
+ <bf:cartographicAttributes>
508
+ <bf:Cartographic>
509
+ <bf:coordinates><xsl:value-of select="normalize-space($vCoordinates)"/></bf:coordinates>
510
+ <xsl:for-each select="marc:subfield[@code='3']">
511
+ <xsl:apply-templates select="." mode="subfield3">
512
+ <xsl:with-param name="serialization" select="$serialization"/>
513
+ </xsl:apply-templates>
514
+ </xsl:for-each>
515
+ </bf:Cartographic>
516
+ </bf:cartographicAttributes>
517
+ </xsl:if>
518
+ <xsl:for-each select="marc:subfield[@code='a']">
519
+ <xsl:if test="text() = 'a' and not(../marc:subfield[@code='b' or @code='c'])">
520
+ <bf:scale>
521
+ <bf:Scale>
522
+ <rdfs:label>linear scale</rdfs:label>
523
+ <xsl:for-each select="../marc:subfield[@code='3']">
524
+ <xsl:apply-templates select="." mode="subfield3">
525
+ <xsl:with-param name="serialization" select="$serialization"/>
526
+ </xsl:apply-templates>
527
+ </xsl:for-each>
528
+ </bf:Scale>
529
+ </bf:scale>
530
+ </xsl:if>
531
+ <xsl:if test="text() = 'b'">
532
+ <bf:scale>
533
+ <bf:Scale>
534
+ <rdfs:label>angular scale</rdfs:label>
535
+ <xsl:for-each select="../marc:subfield[@code='3']">
536
+ <xsl:apply-templates select="." mode="subfield3">
537
+ <xsl:with-param name="serialization" select="$serialization"/>
538
+ </xsl:apply-templates>
539
+ </xsl:for-each>
540
+ </bf:Scale>
541
+ </bf:scale>
542
+ </xsl:if>
543
+ </xsl:for-each>
544
+ <xsl:for-each select="marc:subfield[@code='b']">
545
+ <xsl:apply-templates mode="work034scale" select=".">
546
+ <xsl:with-param name="serialization" select="$serialization"/>
547
+ <xsl:with-param name="pScaleType">linear horizontal</xsl:with-param>
548
+ </xsl:apply-templates>
549
+ </xsl:for-each>
550
+ <xsl:for-each select="marc:subfield[@code='c']">
551
+ <xsl:apply-templates mode="work034scale" select=".">
552
+ <xsl:with-param name="serialization" select="$serialization"/>
553
+ <xsl:with-param name="pScaleType">linear vertical</xsl:with-param>
554
+ </xsl:apply-templates>
555
+ </xsl:for-each>
556
+ </xsl:when>
557
+ </xsl:choose>
558
+ </xsl:template>
559
+
560
+ <xsl:template match="marc:subfield" mode="work034scale">
561
+ <xsl:param name="serialization" select="'rdfxml'"/>
562
+ <xsl:param name="pScaleType"/>
563
+ <xsl:choose>
564
+ <xsl:when test="$serialization = 'rdfxml'">
565
+ <bf:scale>
566
+ <bf:Scale>
567
+ <rdf:value><xsl:value-of select="."/></rdf:value>
568
+ <xsl:if test="$pScaleType != ''">
569
+ <rdfs:label><xsl:value-of select="$pScaleType"/></rdfs:label>
570
+ </xsl:if>
571
+ <xsl:for-each select="../marc:subfield[@code='3']">
572
+ <xsl:apply-templates select="." mode="subfield3">
573
+ <xsl:with-param name="serialization" select="$serialization"/>
574
+ </xsl:apply-templates>
575
+ </xsl:for-each>
576
+ </bf:Scale>
577
+ </bf:scale>
578
+ </xsl:when>
579
+ </xsl:choose>
580
+ </xsl:template>
581
+
582
+ <xsl:template match="marc:datafield[@tag='041' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='041')]" mode="work">
583
+ <xsl:param name="serialization" select="'rdfxml'"/>
584
+ <xsl:variable name="vSource">
585
+ <xsl:choose>
586
+ <xsl:when test="@ind2 = ' '">marc</xsl:when>
587
+ <xsl:when test="@ind2 = '7'"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:when>
588
+ </xsl:choose>
589
+ </xsl:variable>
590
+ <xsl:choose>
591
+ <xsl:when test="$serialization = 'rdfxml'">
592
+ <!--
593
+ <xsl:if test="@ind1 = '1'">
594
+ <bf:note>
595
+ <bf:Note>
596
+ <rdfs:label>Includes translation or is translation</rdfs:label>
597
+ </bf:Note>
598
+ </bf:note>
599
+ </xsl:if>
600
+ -->
601
+ <xsl:for-each select="marc:subfield[@code = 'a'] |
602
+ marc:subfield[@code = 'b'] |
603
+ marc:subfield[@code = 'd'] |
604
+ marc:subfield[@code = 'e'] |
605
+ marc:subfield[@code = 'f'] |
606
+ marc:subfield[@code = 'g'] |
607
+ marc:subfield[@code = 'h'] |
608
+ marc:subfield[@code = 'i'] |
609
+ marc:subfield[@code = 'j'] |
610
+ marc:subfield[@code = 'k'] |
611
+ marc:subfield[@code = 'm'] |
612
+ marc:subfield[@code = 'n'] |
613
+ marc:subfield[@code = 'p'] |
614
+ marc:subfield[@code = 'q'] |
615
+ marc:subfield[@code = 'r'] |
616
+ marc:subfield[@code = 't']">
617
+ <xsl:variable name="sfCode" select="@code" />
618
+ <xsl:variable name="vPart" select="$codeMaps/maps/resourceComponents/*[name() = $sfCode][1]" />
619
+ <xsl:choose>
620
+ <!-- marc language codes can be stacked in the subfield -->
621
+ <xsl:when test="$vSource = 'marc'">
622
+ <xsl:call-template name="parse041">
623
+ <xsl:with-param name="pLang" select="translate(., ' ', '')"/>
624
+ <xsl:with-param name="pPart" select="$vPart"/>
625
+ <xsl:with-param name="p3" select="../marc:subfield[@code='3']"/>
626
+ <xsl:with-param name="pSource" select="'marc'"/>
627
+ <xsl:with-param name="serialization" select="$serialization"/>
628
+ </xsl:call-template>
629
+ </xsl:when>
630
+ <xsl:when test="contains($vSource, '639-1')">
631
+ <xsl:call-template name="parse041">
632
+ <xsl:with-param name="pLang" select="translate(., ' ', '')"/>
633
+ <xsl:with-param name="pPart" select="$vPart"/>
634
+ <xsl:with-param name="p3" select="../marc:subfield[@code='3']"/>
635
+ <xsl:with-param name="pSource" select="'iso6391'"/>
636
+ <xsl:with-param name="serialization" select="$serialization"/>
637
+ </xsl:call-template>
638
+ </xsl:when>
639
+ <xsl:when test="contains($vSource, '639-2')">
640
+ <xsl:call-template name="parse041">
641
+ <xsl:with-param name="pLang" select="translate(., ' ', '')"/>
642
+ <xsl:with-param name="pPart" select="$vPart"/>
643
+ <xsl:with-param name="p3" select="../marc:subfield[@code='3']"/>
644
+ <xsl:with-param name="pSource" select="'iso6392'"/>
645
+ <xsl:with-param name="serialization" select="$serialization"/>
646
+ </xsl:call-template>
647
+ </xsl:when>
648
+ <xsl:when test="contains($vSource, '639-3')">
649
+ <xsl:call-template name="parse041">
650
+ <xsl:with-param name="pLang" select="translate(., ' ', '')"/>
651
+ <xsl:with-param name="pPart" select="$vPart"/>
652
+ <xsl:with-param name="p3" select="../marc:subfield[@code='3']"/>
653
+ <xsl:with-param name="pSource" select="'iso6393'"/>
654
+ <xsl:with-param name="serialization" select="$serialization"/>
655
+ </xsl:call-template>
656
+ </xsl:when>
657
+ <xsl:otherwise>
658
+ <bf:language>
659
+ <bf:Language>
660
+ <rdf:value><xsl:value-of select="."/></rdf:value>
661
+ <xsl:if test="$vPart != ''">
662
+ <bf:part><xsl:value-of select="$vPart/text()"/></bf:part>
663
+ </xsl:if>
664
+ <xsl:apply-templates select="../marc:subfield[@code='2']" mode="subfield2">
665
+ <xsl:with-param name="serialization" select="$serialization"/>
666
+ <xsl:with-param name="pVocabStem" select="$languageschemes"/>
667
+ <xsl:with-param name="pStripPunct" select="true()"/>
668
+ </xsl:apply-templates>
669
+ </bf:Language>
670
+ </bf:language>
671
+ </xsl:otherwise>
672
+ </xsl:choose>
673
+ </xsl:for-each>
674
+ </xsl:when>
675
+ </xsl:choose>
676
+ </xsl:template>
677
+
678
+ <xsl:template name="parse041">
679
+ <xsl:param name="pLang"/>
680
+ <xsl:param name="pPart"/>
681
+ <xsl:param name="p3"/>
682
+ <xsl:param name="pSource"/>
683
+ <xsl:param name="serialization" select="'rdfxml'"/>
684
+ <xsl:param name="pStart" select="1"/>
685
+ <xsl:if test="(string-length($pLang) = 2 and $pSource = 'iso6391') or
686
+ (string-length(substring($pLang,$pStart,3)) = 3)">
687
+ <xsl:variable name="lCode">
688
+ <xsl:call-template name="url-encode">
689
+ <xsl:with-param name="str" select="translate(normalize-space(substring($pLang,$pStart,3)),$upper,$lower)"/>
690
+ </xsl:call-template>
691
+ </xsl:variable>
692
+ <xsl:variable name="match008" select="boolean(substring(../../marc:controlfield[@tag='008'],36,3)=$lCode)" />
693
+ <xsl:variable name="langResource">
694
+ <bf:language>
695
+ <xsl:choose>
696
+ <xsl:when test="$pSource = 'marc'">
697
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($languages,$lCode)"/></xsl:attribute>
698
+ </xsl:when>
699
+ <xsl:when test="$pSource = 'iso6391'">
700
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($iso6391,$lCode)"/></xsl:attribute>
701
+ </xsl:when>
702
+ <xsl:when test="$pSource = 'iso6392'">
703
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($iso6392,$lCode)"/></xsl:attribute>
704
+ </xsl:when>
705
+ <xsl:when test="$pSource = 'iso6393'">
706
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($iso6393,$lCode)"/></xsl:attribute>
707
+ </xsl:when>
708
+ </xsl:choose>
709
+
710
+ </bf:language>
711
+ </xsl:variable>
712
+ <xsl:choose>
713
+ <xsl:when test="$serialization = 'rdfxml'">
714
+ <xsl:choose>
715
+ <xsl:when test="$p3 != ''">
716
+ <!-- "Materials specified. By virtue of this fact alone we need to abstract this. -->
717
+ </xsl:when>
718
+ <xsl:when test="contains('hijkmnpqr', local-name($pPart))">
719
+ <bf:note>
720
+ <bf:Note>
721
+ <rdf:type>
722
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="$pPart/@href"/></xsl:attribute>
723
+ </rdf:type>
724
+ <xsl:copy-of select="$langResource" />
725
+ </bf:Note>
726
+ </bf:note>
727
+ </xsl:when>
728
+ <xsl:when test="contains('bdefgt', local-name($pPart))">
729
+ <bf:accompaniedBy>
730
+ <bf:Work>
731
+ <rdf:type>
732
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="$pPart/@href"/></xsl:attribute>
733
+ </rdf:type>
734
+ <xsl:copy-of select="$langResource" />
735
+ </bf:Work>
736
+ </bf:accompaniedBy>
737
+ </xsl:when>
738
+ <xsl:when test="$pSource != 'marc' and local-name($pPart)='a'">
739
+ <xsl:copy-of select="$langResource" />
740
+ </xsl:when>
741
+ <xsl:when test="local-name($pPart)='a' and not($match008)">
742
+ <xsl:copy-of select="$langResource" />
743
+ </xsl:when>
744
+ </xsl:choose>
745
+ </xsl:when>
746
+ </xsl:choose>
747
+ <xsl:if test="$pSource = 'marc'">
748
+ <xsl:call-template name="parse041">
749
+ <xsl:with-param name="pLang" select="$pLang"/>
750
+ <xsl:with-param name="pPart" select="$pPart"/>
751
+ <xsl:with-param name="p3" select="$p3"/>
752
+ <xsl:with-param name="pSource" select="$pSource"/>
753
+ <xsl:with-param name="serialization" select="$serialization"/>
754
+ <xsl:with-param name="pStart" select="$pStart + 3"/>
755
+ </xsl:call-template>
756
+ </xsl:if>
757
+ </xsl:if>
758
+ </xsl:template>
759
+
760
+ <xsl:template match="marc:datafield[@tag='043' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='043')]" mode="work">
761
+ <xsl:param name="serialization" select="'rdfxml'"/>
762
+ <xsl:choose>
763
+ <xsl:when test="marc:subfield[@code='0'] and starts-with(marc:subfield[@code='0'], 'http')">
764
+ <xsl:for-each select="marc:subfield[@code='0']">
765
+ <xsl:variable name="v0" select="." />
766
+ <xsl:if test="not(parent::marc:datafield/preceding-sibling::marc:datafield[@tag = '043']/marc:subfield[@code='0' and .=$v0])">
767
+ <xsl:if test="contains(., '/authorities/subjects') or
768
+ contains(., '/authorities/names') or
769
+ contains(., '/vocabulary/geographicAreas')">
770
+ <bf:geographicCoverage>
771
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="."/></xsl:attribute>
772
+ </bf:geographicCoverage>
773
+ </xsl:if>
774
+ </xsl:if>
775
+ </xsl:for-each>
776
+ </xsl:when>
777
+ <xsl:otherwise>
778
+ <xsl:for-each select="marc:subfield[@code='a']">
779
+ <xsl:choose>
780
+ <xsl:when test="$serialization='rdfxml'">
781
+ <bf:geographicCoverage>
782
+ <xsl:variable name="vCode">
783
+ <xsl:call-template name="tChopPunct">
784
+ <xsl:with-param name="pString" select="."/>
785
+ <xsl:with-param name="pEndPunct" select="'-'"/>
786
+ </xsl:call-template>
787
+ </xsl:variable>
788
+ <xsl:variable name="encoded">
789
+ <xsl:call-template name="url-encode">
790
+ <xsl:with-param name="str" select="normalize-space($vCode)"/>
791
+ </xsl:call-template>
792
+ </xsl:variable>
793
+ <xsl:attribute name="rdf:resource"><xsl:value-of select="concat($geographicAreas,$encoded)"/></xsl:attribute>
794
+ </bf:geographicCoverage>
795
+ </xsl:when>
796
+ </xsl:choose>
797
+ </xsl:for-each>
798
+ <xsl:for-each select="marc:subfield[@code='b' or @code='c']">
799
+ <xsl:choose>
800
+ <xsl:when test="$serialization='rdfxml'">
801
+ <bf:geographicCoverage>
802
+ <bf:GeographicCoverage>
803
+ <rdf:value><xsl:value-of select="."/></rdf:value>
804
+ <xsl:choose>
805
+ <xsl:when test="@code='c'">
806
+ <bf:source>
807
+ <bf:Source>
808
+ <bf:code>ISO 3166</bf:code>
809
+ </bf:Source>
810
+ </bf:source>
811
+ </xsl:when>
812
+ <xsl:otherwise>
813
+ <xsl:apply-templates select="following-sibling::*[position()=1 or position()=2][@code='2']" mode="subfield2">
814
+ <xsl:with-param name="serialization" select="$serialization"/>
815
+ </xsl:apply-templates>
816
+ <xsl:apply-templates select="following-sibling::*[position()=1 or position()=2][@code='0']" mode="subfield0orw">
817
+ <xsl:with-param name="serialization" select="$serialization"/>
818
+ </xsl:apply-templates>
819
+ </xsl:otherwise>
820
+ </xsl:choose>
821
+ </bf:GeographicCoverage>
822
+ </bf:geographicCoverage>
823
+ </xsl:when>
824
+ </xsl:choose>
825
+ </xsl:for-each>
826
+ </xsl:otherwise>
827
+ </xsl:choose>
828
+ </xsl:template>
829
+
830
+ <xsl:template match="marc:datafield[@tag='045' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='045')]" mode="work">
831
+ <xsl:param name="serialization" select="'rdfxml'"/>
832
+ <xsl:choose>
833
+ <xsl:when test="$serialization='rdfxml'">
834
+ <xsl:for-each select="marc:subfield[@code='a']">
835
+ <bf:temporalCoverage>
836
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="$edtf"/>edtf</xsl:attribute>
837
+ <xsl:call-template name="work045aDate">
838
+ <xsl:with-param name="pDate" select="."/>
839
+ </xsl:call-template>
840
+ </bf:temporalCoverage>
841
+ </xsl:for-each>
842
+ <xsl:choose>
843
+ <xsl:when test="@ind1 = '2'">
844
+ <xsl:variable name="vDate1">
845
+ <xsl:call-template name="work045bDate">
846
+ <xsl:with-param name="pDate" select="marc:subfield[@code='b'][1]"/>
847
+ </xsl:call-template>
848
+ </xsl:variable>
849
+ <xsl:variable name="vDate2">
850
+ <xsl:call-template name="work045bDate">
851
+ <xsl:with-param name="pDate" select="marc:subfield[@code='b'][2]"/>
852
+ </xsl:call-template>
853
+ </xsl:variable>
854
+ <bf:temporalCoverage>
855
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="$edtf"/>edtf</xsl:attribute>
856
+ <xsl:value-of select="concat($vDate1,'/',$vDate2)"/>
857
+ </bf:temporalCoverage>
858
+ </xsl:when>
859
+ <xsl:otherwise>
860
+ <xsl:for-each select="marc:subfield[@code='b']">
861
+ <bf:temporalCoverage>
862
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="$edtf"/>edtf</xsl:attribute>
863
+ <xsl:call-template name="work045bDate">
864
+ <xsl:with-param name="pDate" select="."/>
865
+ </xsl:call-template>
866
+ </bf:temporalCoverage>
867
+ </xsl:for-each>
868
+ </xsl:otherwise>
869
+ </xsl:choose>
870
+ </xsl:when>
871
+ </xsl:choose>
872
+ </xsl:template>
873
+
874
+ <xsl:template name="work045aDate">
875
+ <xsl:param name="pDate"/>
876
+ <xsl:variable name="vDate1">
877
+ <xsl:choose>
878
+ <xsl:when test="substring($pDate,1,1) = 'a'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,1,2)]"/></xsl:when>
879
+ <xsl:when test="substring($pDate,1,1) = 'b'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,1,2)]"/></xsl:when>
880
+ <xsl:when test="substring($pDate,1,1) = 'c'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,1,2)]"/></xsl:when>
881
+ <xsl:when test="substring($pDate,1,1) = 'd'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,1,2)]"/></xsl:when>
882
+ <xsl:when test="substring($pDate,1,1) = 'e'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,1,2)]"/></xsl:when>
883
+ <xsl:otherwise><xsl:value-of select="concat(document('')/*/local:marctimeperiod/*[name() = substring($pDate,1,1)],substring($pDate,2,1),'X')"/></xsl:otherwise>
884
+ </xsl:choose>
885
+ </xsl:variable>
886
+ <xsl:variable name="vDate2">
887
+ <xsl:choose>
888
+ <xsl:when test="substring($pDate,3,1) = 'a'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,3,2)]"/></xsl:when>
889
+ <xsl:when test="substring($pDate,3,1) = 'b'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,3,2)]"/></xsl:when>
890
+ <xsl:when test="substring($pDate,3,1) = 'c'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,3,2)]"/></xsl:when>
891
+ <xsl:when test="substring($pDate,3,1) = 'd'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,3,2)]"/></xsl:when>
892
+ <xsl:when test="substring($pDate,3,1) = 'e'"><xsl:value-of select="document('')/*/local:marctimeperiod/*[name() = substring($pDate,3,2)]"/></xsl:when>
893
+ <xsl:otherwise><xsl:value-of select="concat(document('')/*/local:marctimeperiod/*[name() = substring($pDate,3,1)],substring($pDate,4,1),'X')"/></xsl:otherwise>
894
+ </xsl:choose>
895
+ </xsl:variable>
896
+ <xsl:choose>
897
+ <xsl:when test="$vDate1 = $vDate2"><xsl:value-of select="$vDate1"/></xsl:when>
898
+ <xsl:otherwise><xsl:value-of select="concat($vDate1,'/',$vDate2)"/></xsl:otherwise>
899
+ </xsl:choose>
900
+ </xsl:template>
901
+
902
+ <xsl:template name="work045bDate">
903
+ <xsl:param name="pDate"/>
904
+ <xsl:variable name="vYear">
905
+ <xsl:choose>
906
+ <xsl:when test="substring($pDate,1,1) = 'c'"><xsl:value-of select="concat('-',substring($pDate,2,4))"/></xsl:when>
907
+ <xsl:otherwise><xsl:value-of select="substring($pDate,2,4)"/></xsl:otherwise>
908
+ </xsl:choose>
909
+ </xsl:variable>
910
+ <xsl:variable name="vMonth" select="substring($pDate,6,2)"/>
911
+ <xsl:variable name="vDay" select="substring($pDate,8,2)"/>
912
+ <xsl:variable name="vHour" select="substring($pDate,10,2)"/>
913
+ <xsl:choose>
914
+ <xsl:when test="$vHour != ''"><xsl:value-of select="concat($vYear,'-',$vMonth,'-',$vDay,'T',$vHour)"/></xsl:when>
915
+ <xsl:when test="$vDay != ''"><xsl:value-of select="concat($vYear,'-',$vMonth,'-',$vDay)"/></xsl:when>
916
+ <xsl:when test="$vMonth != ''"><xsl:value-of select="concat($vYear,'-',$vMonth)"/></xsl:when>
917
+ <xsl:otherwise><xsl:value-of select="$vYear"/></xsl:otherwise>
918
+ </xsl:choose>
919
+ </xsl:template>
920
+
921
+ <xsl:template match="marc:datafield[@tag='046' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='046')]" mode="work">
922
+ <xsl:param name="serialization" select="'rdfxml'"/>
923
+ <xsl:variable name="cf008" select="../marc:controlfield[@tag='008']"/>
924
+ <xsl:if test="substring($cf008, 7, 1) != 'r' and marc:subfield[@code='k']">
925
+ <xsl:variable name="vDate1">
926
+ <xsl:call-template name="tMarcToEdtf">
927
+ <xsl:with-param name="pDateString" select="marc:subfield[@code='k']"/>
928
+ </xsl:call-template>
929
+ </xsl:variable>
930
+ <xsl:variable name="vDate2">
931
+ <xsl:if test="marc:subfield[@code='l']">
932
+ <xsl:call-template name="tMarcToEdtf">
933
+ <xsl:with-param name="pDateString" select="marc:subfield[@code='l']"/>
934
+ </xsl:call-template>
935
+ </xsl:if>
936
+ </xsl:variable>
937
+ <xsl:variable name="vDateString">
938
+ <xsl:choose>
939
+ <xsl:when test="$vDate2 != ''">
940
+ <xsl:value-of select="concat($vDate1,'/',$vDate2)"/>
941
+ </xsl:when>
942
+ <xsl:otherwise><xsl:value-of select="$vDate1"/></xsl:otherwise>
943
+ </xsl:choose>
944
+ </xsl:variable>
945
+ <xsl:choose>
946
+ <xsl:when test="$serialization = 'rdfxml'">
947
+ <bf:originDate>
948
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="concat($edtf,'edtf')"/></xsl:attribute>
949
+ <xsl:value-of select="$vDateString"/>
950
+ </bf:originDate>
951
+ </xsl:when>
952
+ </xsl:choose>
953
+ </xsl:if>
954
+ <xsl:if test="marc:subfield[@code='m']">
955
+ <xsl:variable name="vDateM">
956
+ <xsl:call-template name="tMarcToEdtf">
957
+ <xsl:with-param name="pDateString" select="marc:subfield[@code='m']"/>
958
+ </xsl:call-template>
959
+ </xsl:variable>
960
+ <xsl:variable name="vDateN">
961
+ <xsl:if test="marc:subfield[@code='n']">
962
+ <xsl:call-template name="tMarcToEdtf">
963
+ <xsl:with-param name="pDateString" select="marc:subfield[@code='n']"/>
964
+ </xsl:call-template>
965
+ </xsl:if>
966
+ </xsl:variable>
967
+ <xsl:variable name="vDateStringMN">
968
+ <xsl:choose>
969
+ <xsl:when test="$vDateN != ''">
970
+ <xsl:value-of select="concat($vDateM,'/',$vDateN)"/>
971
+ </xsl:when>
972
+ <xsl:otherwise><xsl:value-of select="$vDateM"/></xsl:otherwise>
973
+ </xsl:choose>
974
+ </xsl:variable>
975
+ <xsl:choose>
976
+ <xsl:when test="$serialization = 'rdfxml'">
977
+ <bf:validDate>
978
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="concat($edtf,'edtf')"/></xsl:attribute>
979
+ <xsl:value-of select="$vDateStringMN"/>
980
+ </bf:validDate>
981
+ </xsl:when>
982
+ </xsl:choose>
983
+ </xsl:if>
984
+ </xsl:template>
985
+
986
+ <xsl:template match="marc:datafield[@tag='047' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='047')]" mode="work">
987
+ <xsl:param name="serialization" select="'rdfxml'"/>
988
+ <xsl:choose>
989
+ <xsl:when test="$serialization = 'rdfxml'">
990
+ <xsl:for-each select="marc:subfield[@code='a']">
991
+ <xsl:choose>
992
+ <xsl:when test="../@ind2 = ' '">
993
+ <xsl:call-template name="compForm008">
994
+ <xsl:with-param name="serialization" select="$serialization"/>
995
+ <xsl:with-param name="code" select="."/>
996
+ </xsl:call-template>
997
+ </xsl:when>
998
+ <xsl:otherwise>
999
+ <bf:genreForm>
1000
+ <bf:GenreForm>
1001
+ <bf:code><xsl:value-of select="."/></bf:code>
1002
+ <xsl:apply-templates select="../marc:subfield[@code='2']" mode="subfield2">
1003
+ <xsl:with-param name="serialization" select="$serialization"/>
1004
+ <xsl:with-param name="pVocabStem" select="$musiccompschemes"/>
1005
+ </xsl:apply-templates>
1006
+ </bf:GenreForm>
1007
+ </bf:genreForm>
1008
+ </xsl:otherwise>
1009
+ </xsl:choose>
1010
+ </xsl:for-each>
1011
+ </xsl:when>
1012
+ </xsl:choose>
1013
+ </xsl:template>
1014
+
1015
+ <xsl:template match="marc:datafield[@tag='048' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='048')]" mode="work">
1016
+ <xsl:param name="serialization" select="'rdfxml'"/>
1017
+ <xsl:choose>
1018
+ <xsl:when test="$serialization = 'rdfxml'">
1019
+ <xsl:if test="not(../marc:datafield[@tag='382'])">
1020
+ <bf:ensemble>
1021
+ <bf:Ensemble>
1022
+ <xsl:for-each select="marc:subfield[@code='a' or @code='b']">
1023
+ <xsl:variable name="vCode" select="substring(.,1,2)"/>
1024
+ <xsl:variable name="vCount" select="substring(.,3,2)"/>
1025
+ <xsl:if test="$codeMaps/maps/df048Codes/*[name() = $vCode]">
1026
+ <bf:mediumComponent>
1027
+ <bf:MediumComponent>
1028
+ <bf:mediumOfPerformance>
1029
+ <bf:MediumOfPerformance>
1030
+ <xsl:attribute name="rdf:about">
1031
+ <xsl:value-of select="$codeMaps/maps/df048Codes/*[name() = $vCode]/@href" />
1032
+ </xsl:attribute>
1033
+ <rdfs:label>
1034
+ <xsl:value-of select="$codeMaps/maps/df048Codes/*[name() = $vCode]" />
1035
+ </rdfs:label>
1036
+ </bf:MediumOfPerformance>
1037
+ </bf:mediumOfPerformance>
1038
+ <bf:count>
1039
+ <xsl:choose>
1040
+ <xsl:when test="$vCount = ''">1</xsl:when>
1041
+ <xsl:otherwise><xsl:value-of select="number($vCount)" /></xsl:otherwise>
1042
+ </xsl:choose>
1043
+ </bf:count>
1044
+ <xsl:if test="@code = 'b'">
1045
+ <bf:mediumComponentQualifier>
1046
+ <bf:MediumComponentQualifier rdf:about="http://id.loc.gov/vocabulary/medcompqual/sol">
1047
+ <rdfs:label>solo</rdfs:label>
1048
+ </bf:MediumComponentQualifier>
1049
+ </bf:mediumComponentQualifier>
1050
+ </xsl:if>
1051
+ </bf:MediumComponent>
1052
+ </bf:mediumComponent>
1053
+ </xsl:if>
1054
+ </xsl:for-each>
1055
+ <xsl:if test="marc:subfield[@code='a' or @code='b']">
1056
+ <xsl:choose>
1057
+ <xsl:when test="marc:subfield[(@code='a' or @code='b') and
1058
+ (
1059
+ substring(.,1,1) = 'c' or
1060
+ substring(.,1,1) = 'o'
1061
+ )]">
1062
+ <bf:ensembleSize>
1063
+ <bf:EnsembleSize rdf:about="http://id.loc.gov/vocabulary/ensemblesize/ensemble">
1064
+ <rdfs:label>large ensemble</rdfs:label>
1065
+ </bf:EnsembleSize>
1066
+ </bf:ensembleSize>
1067
+ </xsl:when>
1068
+ <xsl:otherwise>
1069
+ <xsl:variable name="vEnsembleSize">
1070
+ <xsl:call-template name="tallyEnsembleSize">
1071
+ <xsl:with-param name="pNodes" select="marc:subfield[@code='a' or @code='b']" />
1072
+ </xsl:call-template>
1073
+ </xsl:variable>
1074
+ <xsl:choose>
1075
+ <xsl:when test="number($vEnsembleSize) &gt;= 10">
1076
+ <bf:ensembleSize>
1077
+ <bf:EnsembleSize rdf:about="http://id.loc.gov/vocabulary/ensemblesize/ensemble">
1078
+ <rdfs:label>large ensemble</rdfs:label>
1079
+ </bf:EnsembleSize>
1080
+ </bf:ensembleSize>
1081
+ </xsl:when>
1082
+ <xsl:otherwise>
1083
+ <xsl:variable name="vElName" select="concat('_',$vEnsembleSize)"/>
1084
+ <xsl:if test="$codeMaps/maps/ensembleSizes/*[name() = $vElName]">
1085
+ <bf:ensembleSize>
1086
+ <bf:EnsembleSize>
1087
+ <xsl:attribute name="rdf:about">
1088
+ <xsl:value-of select="$codeMaps/maps/ensembleSizes/*[name() = $vElName]/@href" />
1089
+ </xsl:attribute>
1090
+ <rdfs:label>
1091
+ <xsl:value-of select="$codeMaps/maps/ensembleSizes/*[name() = $vElName]" />
1092
+ </rdfs:label>
1093
+ </bf:EnsembleSize>
1094
+ </bf:ensembleSize>
1095
+ </xsl:if>
1096
+ </xsl:otherwise>
1097
+ </xsl:choose>
1098
+ </xsl:otherwise>
1099
+ </xsl:choose>
1100
+ </xsl:if>
1101
+ </bf:Ensemble>
1102
+ </bf:ensemble>
1103
+ </xsl:if>
1104
+ </xsl:when>
1105
+ </xsl:choose>
1106
+ </xsl:template>
1107
+
1108
+ <xsl:template name="tallyEnsembleSize">
1109
+ <xsl:param name="pNodes" />
1110
+ <xsl:param name="pPos" select="1" />
1111
+ <xsl:param name="pTally" select="0" />
1112
+
1113
+ <xsl:variable name="vCount">
1114
+ <xsl:choose>
1115
+ <xsl:when test="substring($pNodes[$pPos],3,2) != ''">
1116
+ <xsl:value-of select="substring($pNodes[$pPos],3,2)"/>
1117
+ </xsl:when>
1118
+ <xsl:otherwise>1</xsl:otherwise>
1119
+ </xsl:choose>
1120
+ </xsl:variable>
1121
+ <xsl:variable name="vNewTally" select="number($pTally) + number($vCount)"/>
1122
+
1123
+ <xsl:variable name="vNextPos" select="number($pPos) + 1"/>
1124
+ <xsl:choose>
1125
+ <xsl:when test="$pNodes[$vNextPos] != ''">
1126
+ <xsl:call-template name="tallyEnsembleSize">
1127
+ <xsl:with-param name="pNodes" select="$pNodes" />
1128
+ <xsl:with-param name="pPos" select="$vNextPos" />
1129
+ <xsl:with-param name="pTally" select="$vNewTally" />
1130
+ </xsl:call-template>
1131
+ </xsl:when>
1132
+ <xsl:otherwise><xsl:value-of select="$vNewTally"/></xsl:otherwise>
1133
+ </xsl:choose>
1134
+ </xsl:template>
1135
+
1136
+ <xsl:template match="marc:datafield[@tag='010' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='010')] |
1137
+ marc:datafield[
1138
+ (@tag='015' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='015')) and
1139
+ marc:subfield[@code = '2'] and not(contains(marc:subfield[@code = 'a'], '***'))
1140
+ ] |
1141
+ marc:datafield[
1142
+ (@tag='016' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='016')) and
1143
+ (@ind1 = ' ' or marc:subfield[@code = '2']) and
1144
+ not(contains(marc:subfield[@code = 'a'], '***'))
1145
+ ] |
1146
+ marc:datafield[@tag='017' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='017')] |
1147
+ marc:datafield[@tag='020' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='020')] |
1148
+ marc:datafield[@tag='024' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='024')] |
1149
+ marc:datafield[@tag='025' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='025')] |
1150
+ marc:datafield[@tag='027' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='027')] |
1151
+ marc:datafield[@tag='028' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='028')] |
1152
+ marc:datafield[@tag='030' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='030')] |
1153
+ marc:datafield[@tag='032' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='032')] |
1154
+ marc:datafield[@tag='035' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='035')] |
1155
+ marc:datafield[@tag='036' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='036')] |
1156
+ marc:datafield[@tag='074' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='074')] |
1157
+ marc:datafield[@tag='088' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='088')]"
1158
+ mode="instance">
1159
+ <xsl:param name="serialization" select="'rdfxml'"/>
1160
+ <xsl:variable name="vTag">
1161
+ <xsl:choose>
1162
+ <xsl:when test="@tag='880'"><xsl:value-of select="substring(marc:subfield[@code='6'],1,3)"/></xsl:when>
1163
+ <xsl:otherwise><xsl:value-of select="@tag"/></xsl:otherwise>
1164
+ </xsl:choose>
1165
+ </xsl:variable>
1166
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
1167
+ <xsl:choose>
1168
+ <xsl:when test="$vTag='010'">
1169
+ <xsl:apply-templates select="." mode="instanceId">
1170
+ <xsl:with-param name="serialization" select="$serialization"/>
1171
+ <xsl:with-param name="pIdentifier">bf:Lccn</xsl:with-param>
1172
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1173
+ </xsl:apply-templates>
1174
+ </xsl:when>
1175
+ <xsl:when test="$vTag='015'">
1176
+ <xsl:apply-templates select="." mode="instanceId">
1177
+ <xsl:with-param name="serialization" select="$serialization"/>
1178
+ <xsl:with-param name="pIdentifier">bf:Nbn</xsl:with-param>
1179
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1180
+ <xsl:with-param name="pChopPunct" select="true()"/>
1181
+ </xsl:apply-templates>
1182
+ </xsl:when>
1183
+ <xsl:when test="$vTag='016'">
1184
+ <xsl:apply-templates select="." mode="instanceId">
1185
+ <xsl:with-param name="serialization" select="$serialization"/>
1186
+ <xsl:with-param name="pIdentifier">bf:Local</xsl:with-param>
1187
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1188
+ </xsl:apply-templates>
1189
+ </xsl:when>
1190
+ <xsl:when test="$vTag='017'">
1191
+ <xsl:apply-templates select="." mode="instanceId">
1192
+ <xsl:with-param name="serialization" select="$serialization"/>
1193
+ <xsl:with-param name="pIdentifier">bf:CopyrightNumber</xsl:with-param>
1194
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1195
+ </xsl:apply-templates>
1196
+ </xsl:when>
1197
+ <xsl:when test="$vTag='020'">
1198
+ <xsl:apply-templates select="." mode="instanceId">
1199
+ <xsl:with-param name="serialization" select="$serialization"/>
1200
+ <xsl:with-param name="pIdentifier">bf:Isbn</xsl:with-param>
1201
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1202
+ <xsl:with-param name="pChopPunct" select="true()"/>
1203
+ </xsl:apply-templates>
1204
+ </xsl:when>
1205
+ <xsl:when test="$vTag='024'">
1206
+ <xsl:variable name="vIdentifier">
1207
+ <xsl:choose>
1208
+ <xsl:when test="@ind1 = '0'">bf:Isrc</xsl:when>
1209
+ <xsl:when test="@ind1 = '1'">bf:Upc</xsl:when>
1210
+ <xsl:when test="@ind1 = '2'">bf:Ismn</xsl:when>
1211
+ <xsl:when test="@ind1 = '3'">bf:Ean</xsl:when>
1212
+ <xsl:when test="@ind1 = '4'">bf:Sici</xsl:when>
1213
+ <xsl:when test="@ind1 = '7'">
1214
+ <xsl:choose>
1215
+ <xsl:when test="marc:subfield[@code='2' and text()='ansi']">bf:Ansi</xsl:when>
1216
+ <xsl:when test="marc:subfield[@code='2' and text()='doi']">bf:Doi</xsl:when>
1217
+ <xsl:when test="marc:subfield[@code='2' and text()='gtin-14']">bf:Gtin14Number</xsl:when>
1218
+ <xsl:when test="marc:subfield[@code='2' and text()='hdl']">bf:Hdl</xsl:when>
1219
+ <xsl:when test="marc:subfield[@code='2' and text()='isan']">bf:Isan</xsl:when>
1220
+ <xsl:when test="marc:subfield[@code='2' and text()='isni']">bf:Isni</xsl:when>
1221
+ <xsl:when test="marc:subfield[@code='2' and text()='iso']">bf:Iso</xsl:when>
1222
+ <xsl:when test="marc:subfield[@code='2' and text()='istc']">bf:Istc</xsl:when>
1223
+ <xsl:when test="marc:subfield[@code='2' and text()='iswc']">bf:Iswc</xsl:when>
1224
+ <xsl:when test="marc:subfield[@code='2' and text()='matrix-number']">bf:MatrixNumber</xsl:when>
1225
+ <xsl:when test="marc:subfield[@code='2' and text()='music-plate']">bf:MusicPlate</xsl:when>
1226
+ <xsl:when test="marc:subfield[@code='2' and text()='music-publisher']">bf:MusicPublisherNumber</xsl:when>
1227
+ <xsl:when test="marc:subfield[@code='2' and text()='stock-number']">bf:StockNumber</xsl:when>
1228
+ <xsl:when test="marc:subfield[@code='2' and text()='urn']">bf:Urn</xsl:when>
1229
+ <xsl:when test="marc:subfield[@code='2' and text()='videorecording-identifier']">bf:VideoRecordingNumber</xsl:when>
1230
+ <!-- do not process EIDR here, process as a Work identifier instead -->
1231
+ <xsl:when test="marc:subfield[@code='2' and text()='eidr']"/>
1232
+ <xsl:otherwise>bf:Identifier</xsl:otherwise>
1233
+ </xsl:choose>
1234
+ </xsl:when>
1235
+ <xsl:otherwise>bf:Identifier</xsl:otherwise>
1236
+ </xsl:choose>
1237
+ </xsl:variable>
1238
+ <xsl:variable name="vUri">
1239
+ <xsl:if test="contains(marc:subfield[@code='0'],'://')">
1240
+ <xsl:variable name="vSource" select="substring(substring-after(marc:subfield[@code='0'],'('),1,string-length(substring-before(marc:subfield[@code='0'],')'))-1)"/>
1241
+ <xsl:choose>
1242
+ <xsl:when test="$vSource != ''"><xsl:value-of select="substring-after(marc:subfield[@code='0'],')')"/></xsl:when>
1243
+ <xsl:otherwise><xsl:value-of select="marc:subfield[@code='0']"/></xsl:otherwise>
1244
+ </xsl:choose>
1245
+ </xsl:if>
1246
+ </xsl:variable>
1247
+ <xsl:if test="$vIdentifier != ''">
1248
+ <xsl:apply-templates select="." mode="instanceId">
1249
+ <xsl:with-param name="serialization" select="$serialization"/>
1250
+ <xsl:with-param name="pIdentifier"><xsl:value-of select="$vIdentifier"/></xsl:with-param>
1251
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1252
+ <xsl:with-param name="pChopPunct" select="true()"/>
1253
+ <xsl:with-param name="pUri" select="$vUri"/>
1254
+ </xsl:apply-templates>
1255
+ </xsl:if>
1256
+ </xsl:when>
1257
+ <xsl:when test="$vTag='025'">
1258
+ <xsl:apply-templates select="." mode="instanceId">
1259
+ <xsl:with-param name="serialization" select="$serialization"/>
1260
+ <xsl:with-param name="pIdentifier">bf:LcOverseasAcq</xsl:with-param>
1261
+ </xsl:apply-templates>
1262
+ </xsl:when>
1263
+ <xsl:when test="$vTag='027'">
1264
+ <xsl:apply-templates select="." mode="instanceId">
1265
+ <xsl:with-param name="serialization" select="$serialization"/>
1266
+ <xsl:with-param name="pIdentifier">bf:Strn</xsl:with-param>
1267
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1268
+ <xsl:with-param name="pChopPunct" select="true()"/>
1269
+ </xsl:apply-templates>
1270
+ </xsl:when>
1271
+ <xsl:when test="$vTag='028'">
1272
+ <xsl:variable name="vIdentifier">
1273
+ <xsl:choose>
1274
+ <xsl:when test="@ind1 = '0'">bf:AudioIssueNumber</xsl:when>
1275
+ <xsl:when test="@ind1 = '1'">bf:MatrixNumber</xsl:when>
1276
+ <xsl:when test="@ind1 = '2'">bf:MusicPlate</xsl:when>
1277
+ <xsl:when test="@ind1 = '3'">bf:MusicPublisherNumber</xsl:when>
1278
+ <xsl:when test="@ind1 = '4'">bf:VideoRecordingNumber</xsl:when>
1279
+ <xsl:when test="@ind1 = '6'">bf:MusicDistributorNumber</xsl:when>
1280
+ <xsl:otherwise>bf:PublisherNumber</xsl:otherwise>
1281
+ </xsl:choose>
1282
+ </xsl:variable>
1283
+ <xsl:apply-templates select="." mode="instanceId">
1284
+ <xsl:with-param name="serialization" select="$serialization"/>
1285
+ <xsl:with-param name="pIdentifier"><xsl:value-of select="$vIdentifier"/></xsl:with-param>
1286
+ <xsl:with-param name="pChopPunct" select="true()"/>
1287
+ </xsl:apply-templates>
1288
+ </xsl:when>
1289
+ <xsl:when test="$vTag='030'">
1290
+ <xsl:apply-templates select="." mode="instanceId">
1291
+ <xsl:with-param name="serialization" select="$serialization"/>
1292
+ <xsl:with-param name="pIdentifier">bf:Coden</xsl:with-param>
1293
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1294
+ </xsl:apply-templates>
1295
+ </xsl:when>
1296
+ <xsl:when test="$vTag='032'">
1297
+ <xsl:apply-templates select="." mode="instanceId">
1298
+ <xsl:with-param name="serialization" select="$serialization"/>
1299
+ <xsl:with-param name="pIdentifier">bf:PostalRegistration</xsl:with-param>
1300
+ </xsl:apply-templates>
1301
+ </xsl:when>
1302
+ <xsl:when test="$vTag='035' and contains(marc:subfield[@code='a'], 'OCoLC')">
1303
+ <xsl:apply-templates select="." mode="instanceId">
1304
+ <xsl:with-param name="serialization" select="$serialization"/>
1305
+ <xsl:with-param name="pIdentifier">bf:OclcNumber</xsl:with-param>
1306
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1307
+ </xsl:apply-templates>
1308
+ </xsl:when>
1309
+ <xsl:when test="$vTag='035'">
1310
+ <xsl:apply-templates select="." mode="instanceId">
1311
+ <xsl:with-param name="serialization" select="$serialization"/>
1312
+ <xsl:with-param name="pIdentifier">bf:Local</xsl:with-param>
1313
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1314
+ </xsl:apply-templates>
1315
+ </xsl:when>
1316
+ <xsl:when test="$vTag='036'">
1317
+ <xsl:apply-templates select="." mode="instanceId">
1318
+ <xsl:with-param name="serialization" select="$serialization"/>
1319
+ <xsl:with-param name="pIdentifier">bf:StudyNumber</xsl:with-param>
1320
+ </xsl:apply-templates>
1321
+ </xsl:when>
1322
+ <xsl:when test="$vTag='074'">
1323
+ <xsl:apply-templates select="." mode="instanceId">
1324
+ <xsl:with-param name="serialization" select="$serialization"/>
1325
+ <xsl:with-param name="pIdentifier">bf:Identifier</xsl:with-param>
1326
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1327
+ </xsl:apply-templates>
1328
+ </xsl:when>
1329
+ <xsl:when test="$vTag='088'">
1330
+ <xsl:apply-templates select="." mode="instanceId">
1331
+ <xsl:with-param name="serialization" select="$serialization"/>
1332
+ <xsl:with-param name="pIdentifier">bf:ReportNumber</xsl:with-param>
1333
+ <xsl:with-param name="pInvalidLabel">invalid</xsl:with-param>
1334
+ </xsl:apply-templates>
1335
+ </xsl:when>
1336
+ </xsl:choose>
1337
+ </xsl:template>
1338
+
1339
+ <xsl:template match="marc:datafield" mode="instanceId">
1340
+ <xsl:param name="serialization" select="'rdfxml'"/>
1341
+ <xsl:param name="pIdentifier" select="'bf:Identifier'"/>
1342
+ <xsl:param name="pIncorrectLabel" select="'incorrect'"/>
1343
+ <xsl:param name="pInvalidLabel" select="'invalid'"/>
1344
+ <xsl:param name="pChopPunct" select="false()"/>
1345
+ <xsl:param name="pUri"/>
1346
+ <xsl:variable name="vTag">
1347
+ <xsl:choose>
1348
+ <xsl:when test="@tag='880'"><xsl:value-of select="substring(marc:subfield[@code='6'],1,3)"/></xsl:when>
1349
+ <xsl:otherwise><xsl:value-of select="@tag"/></xsl:otherwise>
1350
+ </xsl:choose>
1351
+ </xsl:variable>
1352
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
1353
+ <xsl:choose>
1354
+ <xsl:when test="$serialization = 'rdfxml'">
1355
+ <xsl:for-each select="marc:subfield[@code='a' or @code='y' or @code='z']">
1356
+ <xsl:variable name="vId">
1357
+ <xsl:choose>
1358
+ <!-- for 035, extract value after parentheses -->
1359
+ <xsl:when test="$vTag='035' and contains(.,')')"><xsl:value-of select="substring-after(.,')')"/></xsl:when>
1360
+ <!-- for 015,020,024,027 extract value outside parentheses -->
1361
+ <xsl:when test="($vTag='015' or $vTag='020' or $vTag='024' or $vTag='027') and
1362
+ contains(.,'(') and contains(.,')')">
1363
+ <xsl:value-of select="concat(substring-before(.,'('),substring-after(.,')'))"/>
1364
+ </xsl:when>
1365
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
1366
+ </xsl:choose>
1367
+ </xsl:variable>
1368
+ <bf:identifiedBy>
1369
+ <xsl:element name="{$pIdentifier}">
1370
+ <xsl:if test="$pUri != ''">
1371
+ <xsl:attribute name="rdf:about"><xsl:value-of select="$pUri"/></xsl:attribute>
1372
+ </xsl:if>
1373
+ <rdf:value>
1374
+ <xsl:choose>
1375
+ <xsl:when test="$pChopPunct">
1376
+ <xsl:call-template name="tChopPunct">
1377
+ <xsl:with-param name="pString" select="$vId"/>
1378
+ </xsl:call-template>
1379
+ </xsl:when>
1380
+ <xsl:otherwise>
1381
+ <xsl:value-of select="$vId"/>
1382
+ </xsl:otherwise>
1383
+ </xsl:choose>
1384
+ </rdf:value>
1385
+ <xsl:if test="@code = 'z'">
1386
+ <bf:status>
1387
+ <bf:Status>
1388
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/mstatus/cancinv</xsl:attribute>
1389
+ <rdfs:label><xsl:value-of select="$pInvalidLabel"/></rdfs:label>
1390
+ </bf:Status>
1391
+ </bf:status>
1392
+ </xsl:if>
1393
+ <xsl:if test="@code = 'y'">
1394
+ <bf:status>
1395
+ <bf:Status>
1396
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/mstatus/incorrect</xsl:attribute>
1397
+ <rdfs:label><xsl:value-of select="$pIncorrectLabel"/></rdfs:label>
1398
+ </bf:Status>
1399
+ </bf:status>
1400
+ </xsl:if>
1401
+ <!-- special handling for 015, 020, 024, 027 -->
1402
+ <xsl:if test="($vTag='015' or $vTag='020' or $vTag='024' or $vTag='027') and
1403
+ contains(.,'(') and contains(.,')')">
1404
+ <xsl:variable name="vQualifier" select="substring-before(substring-after(.,'('),')')"/>
1405
+ <xsl:if test="$vQualifier != ''">
1406
+ <bf:qualifier>
1407
+ <xsl:if test="$vXmlLang != ''">
1408
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1409
+ </xsl:if>
1410
+ <xsl:call-template name="tChopPunct">
1411
+ <xsl:with-param name="pString" select="$vQualifier"/>
1412
+ </xsl:call-template>
1413
+ </bf:qualifier>
1414
+ </xsl:if>
1415
+ </xsl:if>
1416
+ <!-- special handling for 017, 028, 032, 036 $b -->
1417
+ <xsl:if test="$vTag='017' or $vTag='028' or $vTag='032' or $vTag='036'">
1418
+ <xsl:for-each select="../marc:subfield[@code='b']">
1419
+ <bf:assigner>
1420
+ <bf:Organization>
1421
+ <rdfs:label>
1422
+ <xsl:if test="$vXmlLang != ''">
1423
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1424
+ </xsl:if>
1425
+ <xsl:call-template name="tChopPunct">
1426
+ <xsl:with-param name="pString" select="."/>
1427
+ </xsl:call-template>
1428
+ </rdfs:label>
1429
+ </bf:Organization>
1430
+ </bf:assigner>
1431
+ </xsl:for-each>
1432
+ </xsl:if>
1433
+ <!-- special handling for 020, 024, 036 -->
1434
+ <xsl:if test="$vTag='020' or $vTag='024' or $vTag='036'">
1435
+ <xsl:for-each select="../marc:subfield[@code='c']">
1436
+ <bf:acquisitionTerms>
1437
+ <xsl:if test="$vXmlLang != ''">
1438
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1439
+ </xsl:if>
1440
+ <xsl:call-template name="tChopPunct">
1441
+ <xsl:with-param name="pString" select="."/>
1442
+ </xsl:call-template>
1443
+ </bf:acquisitionTerms>
1444
+ </xsl:for-each>
1445
+ </xsl:if>
1446
+ <xsl:for-each select="../marc:subfield[@code='q']">
1447
+ <bf:qualifier>
1448
+ <xsl:if test="$vXmlLang != ''">
1449
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1450
+ </xsl:if>
1451
+ <xsl:call-template name="tChopPunct">
1452
+ <xsl:with-param name="pString" select="."/>
1453
+ <xsl:with-param name="pChopParens" select="true()"/>
1454
+ </xsl:call-template>
1455
+ </bf:qualifier>
1456
+ </xsl:for-each>
1457
+ <!-- special handling for 017 -->
1458
+ <xsl:if test="$vTag='017'">
1459
+ <xsl:variable name="date"><xsl:value-of select="../marc:subfield[@code='d'][1]"/></xsl:variable>
1460
+ <xsl:variable name="dateformatted"><xsl:value-of select="concat(substring($date,1,4),'-',substring($date,5,2),'-',substring($date,7,2))"/></xsl:variable>
1461
+ <xsl:if test="$date != ''">
1462
+ <bf:date>
1463
+ <xsl:attribute name="rdf:datatype"><xsl:value-of select="$xs"/>date</xsl:attribute>
1464
+ <xsl:value-of select="$dateformatted"/>
1465
+ </bf:date>
1466
+ </xsl:if>
1467
+ </xsl:if>
1468
+ <!-- special handling for 024 -->
1469
+ <xsl:if test="$vTag='024'">
1470
+ <xsl:if test="@code = 'a'">
1471
+ <xsl:for-each select="../marc:subfield[@code='d']">
1472
+ <bf:note>
1473
+ <bf:Note>
1474
+ <rdfs:label>
1475
+ <xsl:if test="$vXmlLang != ''">
1476
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1477
+ </xsl:if>
1478
+ <xsl:value-of select="."/>
1479
+ </rdfs:label>
1480
+ </bf:Note>
1481
+ </bf:note>
1482
+ </xsl:for-each>
1483
+ </xsl:if>
1484
+ </xsl:if>
1485
+ <!-- special handling for source ($2) -->
1486
+ <xsl:choose>
1487
+ <xsl:when test="$vTag='015'">
1488
+ <xsl:apply-templates mode="subfield2" select="../marc:subfield[@code='2']">
1489
+ <xsl:with-param name="serialization" select="$serialization"/>
1490
+ <xsl:with-param name="pVocabStem" select="$nationalbibschemes"/>
1491
+ </xsl:apply-templates>
1492
+ </xsl:when>
1493
+ <xsl:when test="$vTag='016'">
1494
+ <xsl:choose>
1495
+ <xsl:when test="../@ind1 = ' '">
1496
+ <bf:source>
1497
+ <bf:Source>
1498
+ <xsl:attribute name="rdf:about">http://id.loc.gov/authorities/names/no2004037399</xsl:attribute>
1499
+ <rdfs:label>Library and Archives Canada</rdfs:label>
1500
+ </bf:Source>
1501
+ </bf:source>
1502
+ </xsl:when>
1503
+ <xsl:otherwise>
1504
+ <xsl:apply-templates mode="subfield2" select="../marc:subfield[@code='2']">
1505
+ <xsl:with-param name="serialization" select="$serialization"/>
1506
+ <xsl:with-param name="pVocabStem" select="$organizations"/>
1507
+ </xsl:apply-templates>
1508
+ </xsl:otherwise>
1509
+ </xsl:choose>
1510
+ </xsl:when>
1511
+ <xsl:when test="$vTag='022' or $vTag='023'">
1512
+ <xsl:for-each select="../marc:subfield[@code='2']">
1513
+ <bf:assigner>
1514
+ <bf:Agent>
1515
+ <bf:code><xsl:value-of select="."/></bf:code>
1516
+ </bf:Agent>
1517
+ </bf:assigner>
1518
+ </xsl:for-each>
1519
+ </xsl:when>
1520
+ <xsl:when test="$vTag='024'">
1521
+ <xsl:choose>
1522
+ <xsl:when test="$pIdentifier = 'bf:Identifier'">
1523
+ <xsl:apply-templates select="../marc:subfield[@code='2']" mode="subfield2">
1524
+ <xsl:with-param name="serialization" select="$serialization"/>
1525
+ </xsl:apply-templates>
1526
+ </xsl:when>
1527
+ </xsl:choose>
1528
+ </xsl:when>
1529
+ <xsl:when test="$vTag='035' and not(contains(., 'OCoLC'))">
1530
+ <xsl:variable name="vSource" select="substring-before(substring-after(.,'('),')')"/>
1531
+ <xsl:if test="$vSource != ''">
1532
+ <xsl:variable name="vEncoded">
1533
+ <xsl:choose>
1534
+ <xsl:when test="starts-with($vSource, 'DE-')">
1535
+ <xsl:value-of select="normalize-space($vSource)"/>
1536
+ </xsl:when>
1537
+ <xsl:otherwise>
1538
+ <xsl:call-template name="url-encode">
1539
+ <xsl:with-param name="str" select="translate(translate(normalize-space($vSource),'-',''),$upper,$lower)"/>
1540
+ </xsl:call-template>
1541
+ </xsl:otherwise>
1542
+ </xsl:choose>
1543
+ </xsl:variable>
1544
+ <bf:assigner>
1545
+ <bf:Agent>
1546
+ <xsl:choose>
1547
+ <xsl:when test="starts-with($vEncoded, 'DE-')">
1548
+ <xsl:attribute name="rdf:about"><xsl:value-of select="concat($deorgs,$vEncoded)"/></xsl:attribute>
1549
+ </xsl:when>
1550
+ <xsl:otherwise>
1551
+ <xsl:attribute name="rdf:about"><xsl:value-of select="concat($organizations,$vEncoded)"/></xsl:attribute>
1552
+ </xsl:otherwise>
1553
+ </xsl:choose>
1554
+ </bf:Agent>
1555
+ </bf:assigner>
1556
+ </xsl:if>
1557
+ </xsl:when>
1558
+ <xsl:when test="$vTag='074'">
1559
+ <bf:assigner>
1560
+ <bf:Agent>
1561
+ <xsl:attribute name="rdf:about">http://id.loc.gov/vocabulary/organizations/dgpo</xsl:attribute>
1562
+ </bf:Agent>
1563
+ </bf:assigner>
1564
+ </xsl:when>
1565
+ <xsl:otherwise>
1566
+ <xsl:apply-templates select="../marc:subfield[@code='2']" mode="subfield2">
1567
+ <xsl:with-param name="serialization" select="$serialization"/>
1568
+ </xsl:apply-templates>
1569
+ </xsl:otherwise>
1570
+ </xsl:choose>
1571
+ </xsl:element>
1572
+ </bf:identifiedBy>
1573
+ </xsl:for-each>
1574
+ </xsl:when>
1575
+ </xsl:choose>
1576
+ </xsl:template>
1577
+
1578
+ <!-- 026 requires special handling -->
1579
+ <xsl:template match="marc:datafield[@tag='026' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='026')]" mode="instance">
1580
+ <xsl:param name="serialization" select="'rdfxml'"/>
1581
+ <xsl:param name="pHasItem" select="false()"/>
1582
+ <!-- note special $5 processing for LoC below -->
1583
+ <xsl:if test="$pHasItem or not($localfields and marc:subfield[@code='5'])">
1584
+ <xsl:variable name="parsed">
1585
+ <xsl:apply-templates select="marc:subfield[@code='a' or @code='b' or @code='c' or @code='d']" mode="concat-nodes-space"/>
1586
+ </xsl:variable>
1587
+ <xsl:choose>
1588
+ <xsl:when test="$serialization = 'rdfxml'">
1589
+ <bf:identifiedBy>
1590
+ <bf:Fingerprint>
1591
+ <xsl:choose>
1592
+ <xsl:when test="$parsed != ''">
1593
+ <rdf:value><xsl:value-of select="normalize-space($parsed)"/></rdf:value>
1594
+ </xsl:when>
1595
+ <xsl:otherwise>
1596
+ <xsl:for-each select="marc:subfield[@code='e']">
1597
+ <rdf:value><xsl:value-of select="."/></rdf:value>
1598
+ </xsl:for-each>
1599
+ </xsl:otherwise>
1600
+ </xsl:choose>
1601
+ <xsl:apply-templates mode="subfield2" select="marc:subfield[@code='2']">
1602
+ <xsl:with-param name="serialization" select="$serialization"/>
1603
+ <xsl:with-param name="pVocabStem" select="$fingerprintschemes"/>
1604
+ </xsl:apply-templates>
1605
+ <xsl:for-each select="marc:subfield[@code='5']">
1606
+ <xsl:apply-templates select="." mode="subfield5">
1607
+ <xsl:with-param name="serialization" select="$serialization"/>
1608
+ </xsl:apply-templates>
1609
+ </xsl:for-each>
1610
+ </bf:Fingerprint>
1611
+ </bf:identifiedBy>
1612
+ </xsl:when>
1613
+ </xsl:choose>
1614
+ </xsl:if>
1615
+ </xsl:template>
1616
+
1617
+ <xsl:template match="marc:datafield[@tag='037' or (@tag='880' and substring(marc:subfield[@code='6'],1,3)='037')]" mode="instance">
1618
+ <xsl:param name="serialization" select="'rdfxml'"/>
1619
+ <xsl:param name="pHasItem" select="false()"/>
1620
+ <!-- note special $5 processing for LoC below -->
1621
+ <xsl:if test="$pHasItem or not($localfields and marc:subfield[@code='5'])">
1622
+ <xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
1623
+ <xsl:variable name="vAcqSource">
1624
+ <xsl:choose>
1625
+ <xsl:when test="@ind1 = '2'">intervening source</xsl:when>
1626
+ <xsl:when test="@ind1 = '3'">current source</xsl:when>
1627
+ </xsl:choose>
1628
+ </xsl:variable>
1629
+ <xsl:choose>
1630
+ <xsl:when test="$serialization = 'rdfxml'">
1631
+ <bf:acquisitionSource>
1632
+ <bf:AcquisitionSource>
1633
+ <xsl:if test="$vAcqSource != ''">
1634
+ <bf:note>
1635
+ <bf:Note>
1636
+ <rdfs:label><xsl:value-of select="$vAcqSource"/></rdfs:label>
1637
+ </bf:Note>
1638
+ </bf:note>
1639
+ </xsl:if>
1640
+ <xsl:for-each select="marc:subfield[@code='3']">
1641
+ <xsl:apply-templates select="." mode="subfield3">
1642
+ <xsl:with-param name="serialization" select="$serialization"/>
1643
+ </xsl:apply-templates>
1644
+ </xsl:for-each>
1645
+ <xsl:for-each select="marc:subfield[@code='a']">
1646
+ <bf:identifiedBy>
1647
+ <bf:StockNumber>
1648
+ <rdf:value><xsl:value-of select="."/></rdf:value>
1649
+ </bf:StockNumber>
1650
+ </bf:identifiedBy>
1651
+ </xsl:for-each>
1652
+ <xsl:for-each select="marc:subfield[@code='b']">
1653
+ <rdfs:label>
1654
+ <xsl:if test="$vXmlLang != ''">
1655
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1656
+ </xsl:if>
1657
+ <xsl:call-template name="tChopPunct">
1658
+ <xsl:with-param name="pString" select="."/>
1659
+ </xsl:call-template>
1660
+ </rdfs:label>
1661
+ </xsl:for-each>
1662
+ <xsl:for-each select="marc:subfield[@code='c']">
1663
+ <bf:acquisitionTerms>
1664
+ <xsl:if test="$vXmlLang != ''">
1665
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1666
+ </xsl:if>
1667
+ <xsl:call-template name="tChopPunct">
1668
+ <xsl:with-param name="pString" select="."/>
1669
+ </xsl:call-template>
1670
+ </bf:acquisitionTerms>
1671
+ </xsl:for-each>
1672
+ <xsl:for-each select="marc:subfield[@code='f']">
1673
+ <bf:note>
1674
+ <bf:Note>
1675
+ <rdfs:label>
1676
+ <xsl:if test="$vXmlLang != ''">
1677
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1678
+ </xsl:if>
1679
+ <xsl:call-template name="tChopPunct">
1680
+ <xsl:with-param name="pString" select="."/>
1681
+ </xsl:call-template>
1682
+ </rdfs:label>
1683
+ </bf:Note>
1684
+ </bf:note>
1685
+ </xsl:for-each>
1686
+ <xsl:for-each select="marc:subfield[@code='g' or @code='n']">
1687
+ <bf:note>
1688
+ <bf:Note>
1689
+ <rdfs:label>
1690
+ <xsl:if test="$vXmlLang != ''">
1691
+ <xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
1692
+ </xsl:if>
1693
+ <xsl:call-template name="tChopPunct">
1694
+ <xsl:with-param name="pString" select="."/>
1695
+ </xsl:call-template>
1696
+ </rdfs:label>
1697
+ </bf:Note>
1698
+ </bf:note>
1699
+ </xsl:for-each>
1700
+ <xsl:for-each select="marc:subfield[@code='5']">
1701
+ <xsl:apply-templates select="." mode="subfield5">
1702
+ <xsl:with-param name="serialization" select="$serialization"/>
1703
+ </xsl:apply-templates>
1704
+ </xsl:for-each>
1705
+ </bf:AcquisitionSource>
1706
+ </bf:acquisitionSource>
1707
+ </xsl:when>
1708
+ </xsl:choose>
1709
+ </xsl:if>
1710
+ </xsl:template>
1711
+
1712
+ </xsl:stylesheet>