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.
- checksums.yaml +4 -4
- data/README.md +24 -2
- data/docs/superpowers/plans/2026-09-09-marc-conversion.md +537 -0
- data/docs/superpowers/specs/2026-09-09-marc-conversion-design.md +110 -0
- data/lib/bibframe_ruby/marc_converter.rb +67 -0
- data/lib/bibframe_ruby/parser.rb +4 -2
- data/lib/bibframe_ruby/version.rb +1 -1
- data/lib/bibframe_ruby.rb +7 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-001-007.xsl +2276 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-006,008.xsl +1295 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-010-048.xsl +1712 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-050-088.xsl +713 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-1XX,7XX,8XX-names.xsl +1141 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-200-247not240-Titles.xsl +771 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-240andX30-UnifTitle.xsl +535 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-250-270.xsl +283 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-3XX.xsl +2245 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-460-468-SeriesTreat.xsl +135 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-490-510-Links.xsl +145 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-5XX.xsl +1448 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-600-662.xsl +1417 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-720+740to755.xsl +333 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-758.xsl +102 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-760-788-Links.xsl +771 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-841-887.xsl +328 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-880.xsl +119 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-ControlSubfields.xsl +495 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-LDR.xsl +183 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-Preprocess0-Splitting.xsl +765 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-Process6-Series.xsl +627 -0
- data/vendor/marc2bibframe2/xsl/ConvSpec-Process8-ProvAct.xsl +1021 -0
- data/vendor/marc2bibframe2/xsl/conf/abbreviations.xml +13 -0
- data/vendor/marc2bibframe2/xsl/conf/code-to-script.xml +399 -0
- data/vendor/marc2bibframe2/xsl/conf/codeMaps.xml +723 -0
- data/vendor/marc2bibframe2/xsl/conf/exclusions.xml +4 -0
- data/vendor/marc2bibframe2/xsl/conf/iso6392-to-1.xml +615 -0
- data/vendor/marc2bibframe2/xsl/conf/languageCrosswalk.xml +1503 -0
- data/vendor/marc2bibframe2/xsl/conf/map880.xml +175 -0
- data/vendor/marc2bibframe2/xsl/conf/scriptCrosswalk.xml +210 -0
- data/vendor/marc2bibframe2/xsl/conf/subjectThesaurus.xml +29 -0
- data/vendor/marc2bibframe2/xsl/marc2bibframe2.xsl +610 -0
- data/vendor/marc2bibframe2/xsl/naco-normalize.xsl +205 -0
- data/vendor/marc2bibframe2/xsl/utils.xsl +963 -0
- data/vendor/marc2bibframe2/xsl/variables.xsl +108 -0
- metadata +68 -1
|
@@ -0,0 +1,963 @@
|
|
|
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
|
+
<!-- Utility templates -->
|
|
13
|
+
|
|
14
|
+
<!--
|
|
15
|
+
Determine the xml:lang code from $6
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
<xsl:template match="marc:datafield|marc:df" mode="xmllang">
|
|
19
|
+
<xsl:variable name="vLang008"><xsl:value-of select="substring(../marc:controlfield[@tag='008'],36,3)"/></xsl:variable>
|
|
20
|
+
<xsl:choose>
|
|
21
|
+
<xsl:when test="marc:subfield[@code='7' and contains(., '(bcp47)')]">
|
|
22
|
+
<xsl:variable name="bcp47code" select="substring-after(marc:subfield[@code='7' and contains(., '(bcp47)')], ')')"/>
|
|
23
|
+
<xsl:call-template name="normalize-bcp47-lc">
|
|
24
|
+
<xsl:with-param name="pCode" select="$bcp47code"/>
|
|
25
|
+
<xsl:with-param name="p008lang" select="$vLang008"/>
|
|
26
|
+
</xsl:call-template>
|
|
27
|
+
</xsl:when>
|
|
28
|
+
<xsl:when test="marc:subfield[@code='7' and contains(., '[bcp47]') and not(contains(., ']en'))]">
|
|
29
|
+
<xsl:variable name="bcp47code" select="substring-after(marc:subfield[@code='7' and contains(., '[bcp47]')], ']')"/>
|
|
30
|
+
<xsl:call-template name="normalize-bcp47-lc">
|
|
31
|
+
<xsl:with-param name="pCode" select="$bcp47code"/>
|
|
32
|
+
<xsl:with-param name="p008lang" select="$vLang008"/>
|
|
33
|
+
</xsl:call-template>
|
|
34
|
+
</xsl:when>
|
|
35
|
+
<xsl:when test="marc:subfield[@code='6' and contains(., '/')] and ../marc:controlfield[@tag='008']">
|
|
36
|
+
<xsl:variable name="vCountry008"><xsl:value-of select="substring(../marc:controlfield[@tag='008'],16,3)"/></xsl:variable>
|
|
37
|
+
<xsl:variable name="vScript6"><xsl:value-of select="substring-after(marc:subfield[@code='6'],'/')"/></xsl:variable>
|
|
38
|
+
<xsl:variable name="vScript6simple">
|
|
39
|
+
<xsl:choose>
|
|
40
|
+
<xsl:when test="contains($vScript6,'/')"><xsl:value-of select="substring-before($vScript6,'/')"/></xsl:when>
|
|
41
|
+
<xsl:otherwise><xsl:value-of select="$vScript6"/></xsl:otherwise>
|
|
42
|
+
</xsl:choose>
|
|
43
|
+
</xsl:variable>
|
|
44
|
+
<xsl:variable name="vLang">
|
|
45
|
+
<xsl:choose>
|
|
46
|
+
<xsl:when test="$iso6392-to-1-map/iso6392-to-1-map/entry[@key=$vLang008]">
|
|
47
|
+
<xsl:value-of select="$iso6392-to-1-map/iso6392-to-1-map/entry[@key=$vLang008]/value" />
|
|
48
|
+
</xsl:when>
|
|
49
|
+
<xsl:otherwise>
|
|
50
|
+
<xsl:value-of select="$vLang008" />
|
|
51
|
+
</xsl:otherwise>
|
|
52
|
+
</xsl:choose>
|
|
53
|
+
</xsl:variable>
|
|
54
|
+
<xsl:variable name="vScript">
|
|
55
|
+
<xsl:choose>
|
|
56
|
+
<xsl:when test="$vScript6simple='(B'">latn</xsl:when>
|
|
57
|
+
<xsl:when test="$vScript6simple='(N'">cyrl</xsl:when>
|
|
58
|
+
<xsl:when test="$vScript6simple='(Q'">cyrl</xsl:when>
|
|
59
|
+
<xsl:when test="$vScript6simple='(S'">grek</xsl:when>
|
|
60
|
+
<xsl:when test="$vScript6simple='(2'">hebr</xsl:when>
|
|
61
|
+
<xsl:when test="$vScript6simple='(3'">arab</xsl:when>
|
|
62
|
+
<xsl:when test="$vScript6simple='(4'">arab</xsl:when>
|
|
63
|
+
|
|
64
|
+
<xsl:when test="$vScript6simple='$1' and $vLang008='kor'">kore</xsl:when>
|
|
65
|
+
<xsl:when test="$vScript6simple='$1' and $vLang008='chi'">hani</xsl:when>
|
|
66
|
+
<xsl:when test="$vScript6simple='$1' and $vLang008='jpn'">jpan</xsl:when>
|
|
67
|
+
<xsl:when test="$vScript6simple='$1' and $vCountry008='ko '">kore</xsl:when>
|
|
68
|
+
<xsl:when test="$vScript6simple='$1' and $vCountry008='cc '">hani</xsl:when>
|
|
69
|
+
<xsl:when test="$vScript6simple='$1' and $vCountry008='ch '">hani</xsl:when>
|
|
70
|
+
<xsl:when test="$vScript6simple='$1' and $vCountry008='ja '">jpan</xsl:when>
|
|
71
|
+
<xsl:when test="$vScript6simple='$1' and $vLang008='ja '">jpan</xsl:when>
|
|
72
|
+
<!--
|
|
73
|
+
OK, we got here and the script may be $1 but we don't yet have a language match.
|
|
74
|
+
Let's try the 041.
|
|
75
|
+
-->
|
|
76
|
+
<xsl:when test="$vScript6simple='$1' and ../marc:datafield[@tag='041']/marc:subfield[@code='a']='chi'">hani</xsl:when>
|
|
77
|
+
<xsl:when test="$vScript6simple='$1' and ../marc:datafield[@tag='041']/marc:subfield[@code='a']='kor'">kore</xsl:when>
|
|
78
|
+
<xsl:when test="$vScript6simple='$1' and ../marc:datafield[@tag='041']/marc:subfield[@code='a']='jpn'">jpan</xsl:when>
|
|
79
|
+
|
|
80
|
+
<!--
|
|
81
|
+
We have a $1 but cannot determine the language, so go with unknown language,
|
|
82
|
+
jpan for script since it is the most inclusive. This is a poor conclusion based on poor data.
|
|
83
|
+
-->
|
|
84
|
+
<xsl:when test="$vScript6simple='$1'">jpan</xsl:when>
|
|
85
|
+
|
|
86
|
+
<xsl:when test="string-length($vScript6simple)=4 and string-length(translate($vScript6simple,concat($upper,$lower),''))=0">
|
|
87
|
+
<xsl:value-of select="translate($vScript6simple,$upper,$lower)"/>
|
|
88
|
+
</xsl:when>
|
|
89
|
+
<xsl:when test="string-length($vScript6simple)=3 and string-length(translate($vScript6simple,'0123456789',''))=0">
|
|
90
|
+
<xsl:value-of select="$scriptMap/xml-scripts/script[@num=$vScript6simple]/@code"/>
|
|
91
|
+
</xsl:when>
|
|
92
|
+
</xsl:choose>
|
|
93
|
+
</xsl:variable>
|
|
94
|
+
<xsl:choose>
|
|
95
|
+
<xsl:when test="$vLang = 'en' and $vScript != '' and $vScript != 'latn'"><xsl:value-of select="concat('und-',$vScript)"/></xsl:when>
|
|
96
|
+
<xsl:when test="$bcp47inferrence and
|
|
97
|
+
$code-to-script-map/code-to-script-map/entry[@key=$vLang] and
|
|
98
|
+
$code-to-script-map/code-to-script-map/entry[@key=$vLang]/value != $vScript">
|
|
99
|
+
<xsl:value-of select="concat($vLang,'-',$vScript)"/>
|
|
100
|
+
</xsl:when>
|
|
101
|
+
<xsl:when test="$bcp47inferrence and $code-to-script-map/code-to-script-map/entry[@key=$vLang]">
|
|
102
|
+
<xsl:value-of select="$vLang" />
|
|
103
|
+
</xsl:when>
|
|
104
|
+
<xsl:when test="$vLang != '' and $vScript != ''"><xsl:value-of select="concat($vLang,'-',$vScript)"/></xsl:when>
|
|
105
|
+
<xsl:when test="$vScript != ''"><xsl:value-of select="concat('und-',$vScript)"/></xsl:when>
|
|
106
|
+
</xsl:choose>
|
|
107
|
+
</xsl:when>
|
|
108
|
+
<xsl:when test="@tag = '242'">
|
|
109
|
+
<xsl:variable name="bcp47code" select="translate(marc:subfield[@code='y'], '.', '')"/>
|
|
110
|
+
<xsl:call-template name="normalize-bcp47-lc">
|
|
111
|
+
<xsl:with-param name="pCode" select="$bcp47code"/>
|
|
112
|
+
<xsl:with-param name="p008lang" select="$vLang008"/>
|
|
113
|
+
</xsl:call-template>
|
|
114
|
+
</xsl:when>
|
|
115
|
+
<xsl:when test="marc:subfield[@code='7' and contains(., '(bcp47/')]">
|
|
116
|
+
<xsl:variable name="bcp47code" select="substring-after(marc:subfield[@code='7' and contains(., '(bcp47/')], ')')"/>
|
|
117
|
+
<xsl:call-template name="normalize-bcp47-lc">
|
|
118
|
+
<xsl:with-param name="pCode" select="$bcp47code"/>
|
|
119
|
+
<xsl:with-param name="p008lang" select="$vLang008"/>
|
|
120
|
+
</xsl:call-template>
|
|
121
|
+
</xsl:when>
|
|
122
|
+
<xsl:when test="marc:sf[@code='7' and contains(., '(bcp47/')]">
|
|
123
|
+
<xsl:variable name="bcp47code" select="substring-after(marc:sf[@code='7' and contains(., '(bcp47/')], ')')"/>
|
|
124
|
+
<xsl:call-template name="normalize-bcp47-lc">
|
|
125
|
+
<xsl:with-param name="pCode" select="$bcp47code"/>
|
|
126
|
+
<xsl:with-param name="p008lang" select="$vLang008"/>
|
|
127
|
+
</xsl:call-template>
|
|
128
|
+
</xsl:when>
|
|
129
|
+
</xsl:choose>
|
|
130
|
+
</xsl:template>
|
|
131
|
+
|
|
132
|
+
<xsl:template match="marc:datafield|marc:df" mode="xmllang-attribute">
|
|
133
|
+
<xsl:param name="pSFCode"/>
|
|
134
|
+
<xsl:param name="pXMLlang"/>
|
|
135
|
+
|
|
136
|
+
<xsl:variable name="vLang008"><xsl:value-of select="substring(../marc:controlfield[@tag='008'],36,3)"/></xsl:variable>
|
|
137
|
+
<xsl:variable name="vDPcode" select="concat('(bcp47/dpsf', $pSFCode, ')')" />
|
|
138
|
+
|
|
139
|
+
<xsl:choose>
|
|
140
|
+
<xsl:when test="marc:subfield[@code='7' and contains(., $vDPcode)]">
|
|
141
|
+
<xsl:variable name="bcp47code" select="substring-after(marc:subfield[@code='7' and contains(., $vDPcode)], ')')"/>
|
|
142
|
+
<!-- <xsl:message><xsl:value-of select="$bcp47code"/></xsl:message> -->
|
|
143
|
+
<xsl:variable name="vXMLlang">
|
|
144
|
+
<xsl:call-template name="normalize-bcp47-lc">
|
|
145
|
+
<xsl:with-param name="pCode" select="$bcp47code"/>
|
|
146
|
+
<xsl:with-param name="p008lang" select="$vLang008"/>
|
|
147
|
+
</xsl:call-template>
|
|
148
|
+
</xsl:variable>
|
|
149
|
+
<xsl:attribute name="xml:lang"><xsl:value-of select="$vXMLlang"/></xsl:attribute>
|
|
150
|
+
</xsl:when>
|
|
151
|
+
<xsl:when test="marc:sf[@code='7' and contains(., $vDPcode)]">
|
|
152
|
+
<xsl:variable name="bcp47code" select="substring-after(marc:sf[@code='7' and contains(., $vDPcode)], ')')"/>
|
|
153
|
+
<!-- <xsl:message><xsl:value-of select="$bcp47code"/></xsl:message> -->
|
|
154
|
+
<xsl:variable name="vXMLlang">
|
|
155
|
+
<xsl:call-template name="normalize-bcp47-lc">
|
|
156
|
+
<xsl:with-param name="pCode" select="$bcp47code"/>
|
|
157
|
+
<xsl:with-param name="p008lang" select="$vLang008"/>
|
|
158
|
+
</xsl:call-template>
|
|
159
|
+
</xsl:variable>
|
|
160
|
+
<xsl:attribute name="xml:lang"><xsl:value-of select="$vXMLlang"/></xsl:attribute>
|
|
161
|
+
</xsl:when>
|
|
162
|
+
<xsl:when test="$pXMLlang != ''">
|
|
163
|
+
<xsl:attribute name="xml:lang"><xsl:value-of select="$pXMLlang"/></xsl:attribute>
|
|
164
|
+
</xsl:when>
|
|
165
|
+
</xsl:choose>
|
|
166
|
+
</xsl:template>
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
<xsl:template name="normalize-bcp47-lc">
|
|
170
|
+
<xsl:param name="pCode"/>
|
|
171
|
+
<xsl:param name="p008lang"/>
|
|
172
|
+
|
|
173
|
+
<xsl:choose>
|
|
174
|
+
<xsl:when test="contains($pCode, '-t-')">
|
|
175
|
+
<xsl:value-of select="$pCode"/>
|
|
176
|
+
</xsl:when>
|
|
177
|
+
<xsl:otherwise>
|
|
178
|
+
|
|
179
|
+
<xsl:variable name="pCode1">
|
|
180
|
+
<xsl:choose>
|
|
181
|
+
<xsl:when test="contains($pCode, '-')">
|
|
182
|
+
<xsl:value-of select="substring-before($pCode, '-')" />
|
|
183
|
+
</xsl:when>
|
|
184
|
+
<xsl:otherwise>
|
|
185
|
+
<xsl:value-of select="$pCode" />
|
|
186
|
+
</xsl:otherwise>
|
|
187
|
+
</xsl:choose>
|
|
188
|
+
</xsl:variable>
|
|
189
|
+
<xsl:variable name="pLangCode">
|
|
190
|
+
<xsl:choose>
|
|
191
|
+
<xsl:when test="string-length($pCode1) = '3'">
|
|
192
|
+
<!-- 3 character code, let's see if we have a two character equivalent. -->
|
|
193
|
+
<xsl:choose>
|
|
194
|
+
<xsl:when test="$iso6392-to-1-map/iso6392-to-1-map/entry[@key=$pCode1]">
|
|
195
|
+
<xsl:value-of select="$iso6392-to-1-map/iso6392-to-1-map/entry[@key=$pCode1]/value" />
|
|
196
|
+
</xsl:when>
|
|
197
|
+
<xsl:when test="($pCode1 = 'zxx' or $pCode1 = 'und') and $iso6392-to-1-map/iso6392-to-1-map/entry[@key=$p008lang]/value">
|
|
198
|
+
<xsl:value-of select="$iso6392-to-1-map/iso6392-to-1-map/entry[@key=$p008lang]/value" />
|
|
199
|
+
</xsl:when>
|
|
200
|
+
<xsl:otherwise>
|
|
201
|
+
<xsl:value-of select="$pCode1" />
|
|
202
|
+
</xsl:otherwise>
|
|
203
|
+
</xsl:choose>
|
|
204
|
+
</xsl:when>
|
|
205
|
+
<xsl:otherwise>
|
|
206
|
+
<!-- Just going to presume a 2 character code for now. -->
|
|
207
|
+
<xsl:value-of select="$pCode1" />
|
|
208
|
+
</xsl:otherwise>
|
|
209
|
+
</xsl:choose>
|
|
210
|
+
</xsl:variable>
|
|
211
|
+
|
|
212
|
+
<xsl:variable name="pCode2">
|
|
213
|
+
<xsl:choose>
|
|
214
|
+
<xsl:when test="contains($pCode, '-')">
|
|
215
|
+
<xsl:value-of select="translate(substring-after($pCode, '-'), $upper, $lower)" />
|
|
216
|
+
</xsl:when>
|
|
217
|
+
</xsl:choose>
|
|
218
|
+
</xsl:variable>
|
|
219
|
+
<xsl:variable name="pScriptCode">
|
|
220
|
+
<xsl:choose>
|
|
221
|
+
<xsl:when test="$pCode2 != '' and string-length($pCode2) = '4'">
|
|
222
|
+
<!-- Let's assume we have a script code already. -->
|
|
223
|
+
<xsl:choose>
|
|
224
|
+
<!--
|
|
225
|
+
Desire to output a bcp47 code that adheres to the bcp47 rules,
|
|
226
|
+
which produce codes with variations depending on rules the bcp47 people
|
|
227
|
+
established. So if $bcp47normalize is true *and* this language code is found
|
|
228
|
+
in the code-to-script map, the script should be omitted in this scenario.
|
|
229
|
+
There will doubtless be people who complain about the first character of the
|
|
230
|
+
script code not being capitalized. The horror!!!
|
|
231
|
+
-->
|
|
232
|
+
<xsl:when test="$bcp47inferrence and
|
|
233
|
+
$code-to-script-map/code-to-script-map/entry[@key=$pLangCode] and
|
|
234
|
+
$code-to-script-map/code-to-script-map/entry[@key=$pLangCode]/value != $pCode2">
|
|
235
|
+
<xsl:value-of select="$pCode2"/>
|
|
236
|
+
</xsl:when>
|
|
237
|
+
<xsl:when test="$bcp47inferrence and $code-to-script-map/code-to-script-map/entry[@key=$pLangCode]" />
|
|
238
|
+
<xsl:otherwise><xsl:value-of select="$pCode2"/></xsl:otherwise>
|
|
239
|
+
</xsl:choose>
|
|
240
|
+
</xsl:when>
|
|
241
|
+
<xsl:when test="$pCode2 = '' and not($bcp47inferrence) and $code-to-script-map/code-to-script-map/entry[@key=$pLangCode]">
|
|
242
|
+
<xsl:value-of select="$code-to-script-map/code-to-script-map/entry[@key=$pLangCode]"/>
|
|
243
|
+
</xsl:when>
|
|
244
|
+
</xsl:choose>
|
|
245
|
+
</xsl:variable>
|
|
246
|
+
|
|
247
|
+
<xsl:choose>
|
|
248
|
+
<xsl:when test="$pScriptCode != ''">
|
|
249
|
+
<xsl:value-of select="translate(concat($pLangCode, '-', $pScriptCode), ' ', '')"/>
|
|
250
|
+
</xsl:when>
|
|
251
|
+
<xsl:otherwise>
|
|
252
|
+
<xsl:value-of select="$pLangCode"/>
|
|
253
|
+
</xsl:otherwise>
|
|
254
|
+
</xsl:choose>
|
|
255
|
+
|
|
256
|
+
</xsl:otherwise>
|
|
257
|
+
</xsl:choose>
|
|
258
|
+
</xsl:template>
|
|
259
|
+
|
|
260
|
+
<!--
|
|
261
|
+
rudimentary LCC validation
|
|
262
|
+
returns "true" if valid, "" if not valid
|
|
263
|
+
-->
|
|
264
|
+
<xsl:template name="validateLCC">
|
|
265
|
+
<xsl:param name="pCall"/>
|
|
266
|
+
<xsl:variable name="vAlpha">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
|
|
267
|
+
<xsl:variable name="vNumber">0123456789</xsl:variable>
|
|
268
|
+
<xsl:if test="string-length(translate(substring($pCall,1,1),$vAlpha,''))=0">
|
|
269
|
+
<xsl:choose>
|
|
270
|
+
<xsl:when test="string-length(translate(substring($pCall,2,1),$vAlpha,''))=0">
|
|
271
|
+
<xsl:choose>
|
|
272
|
+
<xsl:when test="string-length(translate(substring($pCall,3,1),$vAlpha,''))=0">
|
|
273
|
+
<xsl:if test="string-length(translate(substring($pCall,4,1),$vNumber,''))=0">true</xsl:if>
|
|
274
|
+
</xsl:when>
|
|
275
|
+
<xsl:when test="string-length(translate(substring($pCall,3,1),$vNumber,''))=0">true</xsl:when>
|
|
276
|
+
</xsl:choose>
|
|
277
|
+
</xsl:when>
|
|
278
|
+
<xsl:when test="string-length(translate(substring($pCall,2,1),$vNumber,''))=0">true</xsl:when>
|
|
279
|
+
</xsl:choose>
|
|
280
|
+
</xsl:if>
|
|
281
|
+
</xsl:template>
|
|
282
|
+
|
|
283
|
+
<!--
|
|
284
|
+
Process 7 punctuation handling
|
|
285
|
+
-->
|
|
286
|
+
<xsl:template name="tChopPunct">
|
|
287
|
+
<xsl:param name="pString"/>
|
|
288
|
+
<xsl:param name="pEndPunct" select="'.:;,/='"/>
|
|
289
|
+
<xsl:param name="pTermPunct" select="'.?!'"/>
|
|
290
|
+
<xsl:param name="pLeadPunct" select="';='"/>
|
|
291
|
+
<xsl:param name="pForceTerm" select="false()"/>
|
|
292
|
+
<xsl:param name="pChopParens" select="false()"/>
|
|
293
|
+
<xsl:param name="pAddBrackets" select="false()"/>
|
|
294
|
+
<xsl:variable name="vNormString" select="normalize-space($pString)"/>
|
|
295
|
+
<xsl:variable name="vLength" select="string-length($vNormString)"/>
|
|
296
|
+
<xsl:choose>
|
|
297
|
+
|
|
298
|
+
<!-- no processing needed for empty string -->
|
|
299
|
+
<xsl:when test="not($vNormString) or $vLength=0"/>
|
|
300
|
+
|
|
301
|
+
<!-- remove enclosing parens when pChopParens is true -->
|
|
302
|
+
<xsl:when test="substring($vNormString,1,1) = '(' and $pChopParens">
|
|
303
|
+
<xsl:variable name="vCloseIndex">
|
|
304
|
+
<xsl:call-template name="tLastIndex">
|
|
305
|
+
<xsl:with-param name="pString" select="$vNormString"/>
|
|
306
|
+
<xsl:with-param name="pSearch" select="')'"/>
|
|
307
|
+
</xsl:call-template>
|
|
308
|
+
</xsl:variable>
|
|
309
|
+
<xsl:choose>
|
|
310
|
+
<xsl:when test="$vCloseIndex > 2">
|
|
311
|
+
<xsl:call-template name="tChopPunct">
|
|
312
|
+
<xsl:with-param name="pString" select="concat(substring($vNormString,2,$vCloseIndex - 2),substring($vNormString,$vCloseIndex+1))"/>
|
|
313
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
314
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
315
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
316
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
317
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
318
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
319
|
+
</xsl:call-template>
|
|
320
|
+
</xsl:when>
|
|
321
|
+
<xsl:otherwise>
|
|
322
|
+
<xsl:call-template name="tChopPunct">
|
|
323
|
+
<xsl:with-param name="pString" select="substring($vNormString,2)"/>
|
|
324
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
325
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
326
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
327
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
328
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
329
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
330
|
+
</xsl:call-template>
|
|
331
|
+
</xsl:otherwise>
|
|
332
|
+
</xsl:choose>
|
|
333
|
+
</xsl:when>
|
|
334
|
+
|
|
335
|
+
<!-- remove leading punctuation for combined works, parallel titles -->
|
|
336
|
+
<xsl:when test="contains($pLeadPunct,substring($vNormString,1,1))">
|
|
337
|
+
<xsl:call-template name="tChopPunct">
|
|
338
|
+
<xsl:with-param name="pString" select="substring($vNormString,2)"/>
|
|
339
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
340
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
341
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
342
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
343
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
344
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
345
|
+
</xsl:call-template>
|
|
346
|
+
</xsl:when>
|
|
347
|
+
|
|
348
|
+
<!--
|
|
349
|
+
enclosing punctuation routines do not take into account
|
|
350
|
+
multiple parenthetical clauses that are unbalanced
|
|
351
|
+
e.g.: '(something) (something else' will not strip the second
|
|
352
|
+
open parens
|
|
353
|
+
-->
|
|
354
|
+
|
|
355
|
+
<!-- remove lead enclosing punctuation if end character is not in string -->
|
|
356
|
+
<xsl:when test="contains($vNormString,'(') and not(contains(substring-after($vNormString,'('),')'))">
|
|
357
|
+
<xsl:call-template name="tChopPunct">
|
|
358
|
+
<xsl:with-param name="pString" select="concat(substring-before($vNormString,'('),substring-after($vNormString,'('))"/>
|
|
359
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
360
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
361
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
362
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
363
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
364
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
365
|
+
</xsl:call-template>
|
|
366
|
+
</xsl:when>
|
|
367
|
+
<xsl:when test="contains($vNormString,'{{') and not(contains(substring-after($vNormString,'{{'),'}}'))">
|
|
368
|
+
<xsl:call-template name="tChopPunct">
|
|
369
|
+
<xsl:with-param name="pString" select="concat(substring-before($vNormString,'{{'),substring-after($vNormString,'{{'))"/>
|
|
370
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
371
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
372
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
373
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
374
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
375
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
376
|
+
</xsl:call-template>
|
|
377
|
+
</xsl:when>
|
|
378
|
+
<!-- actually this accounts well enough for both lead and closing quotes -->
|
|
379
|
+
<xsl:when test="contains($vNormString,'"') and not(contains(substring-after($vNormString,'"'),'"'))">
|
|
380
|
+
<xsl:call-template name="tChopPunct">
|
|
381
|
+
<xsl:with-param name="pString" select="concat(substring-before($vNormString,'"'),substring-after($vNormString,'"'))"/>
|
|
382
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
383
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
384
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
385
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
386
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
387
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
388
|
+
</xsl:call-template>
|
|
389
|
+
</xsl:when>
|
|
390
|
+
|
|
391
|
+
<!-- remove end enclosing punctuation if start character is not in string -->
|
|
392
|
+
<xsl:when test="contains($vNormString,')') and not(contains(substring-before($vNormString,')'),'('))">
|
|
393
|
+
<xsl:call-template name="tChopPunct">
|
|
394
|
+
<xsl:with-param name="pString" select="concat(substring-before($vNormString,')'),substring-after($vNormString,')'))"/>
|
|
395
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
396
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
397
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
398
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
399
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
400
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
401
|
+
</xsl:call-template>
|
|
402
|
+
</xsl:when>
|
|
403
|
+
<xsl:when test="contains($vNormString,'}}') and not(contains(substring-before($vNormString,'}}'),'{{'))">
|
|
404
|
+
<xsl:call-template name="tChopPunct">
|
|
405
|
+
<xsl:with-param name="pString" select="concat(substring-before($vNormString,'}}'),substring-after($vNormString,'}}'))"/>
|
|
406
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
407
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
408
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
409
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
410
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
411
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
412
|
+
</xsl:call-template>
|
|
413
|
+
</xsl:when>
|
|
414
|
+
|
|
415
|
+
<!--
|
|
416
|
+
This has been added to deal with what appears to be a bug
|
|
417
|
+
in the MarkLogic XSLT processor. It has been reported.
|
|
418
|
+
-->
|
|
419
|
+
<xsl:when test="substring($vNormString,$vLength,1)='︡'">
|
|
420
|
+
<xsl:call-template name="tBalanceBrackets">
|
|
421
|
+
<xsl:with-param name="pString" select="$vNormString"/>
|
|
422
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
423
|
+
</xsl:call-template>
|
|
424
|
+
</xsl:when>
|
|
425
|
+
|
|
426
|
+
<!-- special handling for ending periods -->
|
|
427
|
+
<!-- do not remove if we think it is an initial -->
|
|
428
|
+
<!-- do not remove if we think it is an abbreviation -->
|
|
429
|
+
<!-- do not remove if we there there are multiple sentences, unless the string contains initials -->
|
|
430
|
+
<!-- note that for multiple sentences where string contains initials, end punctuation will be stripped -->
|
|
431
|
+
<!-- note that abbreviations within the string will be detected as multiple sentences -->
|
|
432
|
+
<!-- do not fire if $pForceTerm = true() -->
|
|
433
|
+
<xsl:when test="contains($pEndPunct,'.') and not($pForceTerm) and substring($vNormString,$vLength,1)='.'">
|
|
434
|
+
<xsl:variable name="vInitials">
|
|
435
|
+
<xsl:call-template name="tFindInitials">
|
|
436
|
+
<xsl:with-param name="pString" select="substring($vNormString,1,$vLength - 1)"/>
|
|
437
|
+
</xsl:call-template>
|
|
438
|
+
</xsl:variable>
|
|
439
|
+
<xsl:variable name="vEndAbbrev">
|
|
440
|
+
<xsl:for-each select="$abbreviations/abbreviations/abbrev">
|
|
441
|
+
<xsl:if test="concat(' ',@text) = substring($vNormString,$vLength - string-length(@text)) or
|
|
442
|
+
@text = $vNormString">
|
|
443
|
+
<xsl:value-of select="true()"/>
|
|
444
|
+
</xsl:if>
|
|
445
|
+
</xsl:for-each>
|
|
446
|
+
</xsl:variable>
|
|
447
|
+
<xsl:choose>
|
|
448
|
+
<!-- Let's say it's an initial if the previous 2 characters are [ .][A-Z] -->
|
|
449
|
+
<xsl:when test="contains($upper,substring($vNormString,$vLength - 1,1)) and
|
|
450
|
+
contains(' .',substring($vNormString,$vLength - 2,1))">
|
|
451
|
+
<xsl:call-template name="tBalanceBrackets">
|
|
452
|
+
<xsl:with-param name="pString" select="$vNormString"/>
|
|
453
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
454
|
+
</xsl:call-template>
|
|
455
|
+
</xsl:when>
|
|
456
|
+
<xsl:when test="$vInitials='true'">
|
|
457
|
+
<xsl:call-template name="tChopPunct">
|
|
458
|
+
<xsl:with-param name="pString" select="substring($vNormString,1,$vLength - 1)"/>
|
|
459
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
460
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
461
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
462
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
463
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
464
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
465
|
+
</xsl:call-template>
|
|
466
|
+
</xsl:when>
|
|
467
|
+
<xsl:when test="$vEndAbbrev='true'">
|
|
468
|
+
<xsl:call-template name="tBalanceBrackets">
|
|
469
|
+
<xsl:with-param name="pString" select="$vNormString"/>
|
|
470
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
471
|
+
</xsl:call-template>
|
|
472
|
+
</xsl:when>
|
|
473
|
+
<!-- Let's say there are multiple sentences if terminal punctuation can be found in the rest of the string -->
|
|
474
|
+
<xsl:when test="not(string-length(substring($vNormString,1,$vLength - 1)) = string-length(translate(substring($vNormString,1,$vLength - 1),$pTermPunct,'')))">
|
|
475
|
+
<xsl:call-template name="tBalanceBrackets">
|
|
476
|
+
<xsl:with-param name="pString" select="$vNormString"/>
|
|
477
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
478
|
+
</xsl:call-template>
|
|
479
|
+
</xsl:when>
|
|
480
|
+
<xsl:otherwise>
|
|
481
|
+
<xsl:call-template name="tChopPunct">
|
|
482
|
+
<xsl:with-param name="pString" select="substring($vNormString,1,$vLength - 1)"/>
|
|
483
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
484
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
485
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
486
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
487
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
488
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
489
|
+
</xsl:call-template>
|
|
490
|
+
</xsl:otherwise>
|
|
491
|
+
</xsl:choose>
|
|
492
|
+
</xsl:when>
|
|
493
|
+
|
|
494
|
+
<!-- generic case: strip ending punctuation -->
|
|
495
|
+
<xsl:when test="contains($pEndPunct, substring($vNormString,$vLength,1))">
|
|
496
|
+
<xsl:call-template name="tChopPunct">
|
|
497
|
+
<xsl:with-param name="pString" select="substring($vNormString,1,$vLength - 1)"/>
|
|
498
|
+
<xsl:with-param name="pEndPunct" select="$pEndPunct"/>
|
|
499
|
+
<xsl:with-param name="pLeadPunct" select="$pLeadPunct"/>
|
|
500
|
+
<xsl:with-param name="pTermPunct" select="$pTermPunct"/>
|
|
501
|
+
<xsl:with-param name="pForceTerm" select="$pForceTerm"/>
|
|
502
|
+
<xsl:with-param name="pChopParens" select="$pChopParens"/>
|
|
503
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
504
|
+
</xsl:call-template>
|
|
505
|
+
</xsl:when>
|
|
506
|
+
|
|
507
|
+
<xsl:otherwise>
|
|
508
|
+
<!-- add matching square brackets if missing -->
|
|
509
|
+
<xsl:call-template name="tBalanceBrackets">
|
|
510
|
+
<xsl:with-param name="pString" select="$vNormString"/>
|
|
511
|
+
<xsl:with-param name="pAddBrackets" select="$pAddBrackets"/>
|
|
512
|
+
</xsl:call-template>
|
|
513
|
+
</xsl:otherwise>
|
|
514
|
+
</xsl:choose>
|
|
515
|
+
</xsl:template>
|
|
516
|
+
|
|
517
|
+
<xsl:template name="tLastIndex">
|
|
518
|
+
<xsl:param name="pString"/>
|
|
519
|
+
<xsl:param name="pSearch"/>
|
|
520
|
+
<xsl:choose>
|
|
521
|
+
<xsl:when test="$pSearch != '' and contains($pString,$pSearch)">
|
|
522
|
+
<xsl:variable name="vRevSearch">
|
|
523
|
+
<xsl:call-template name="tReverseString">
|
|
524
|
+
<xsl:with-param name="pString" select="$pSearch"/>
|
|
525
|
+
</xsl:call-template>
|
|
526
|
+
</xsl:variable>
|
|
527
|
+
<xsl:variable name="vRevString">
|
|
528
|
+
<xsl:call-template name="tReverseString">
|
|
529
|
+
<xsl:with-param name="pString" select="$pString"/>
|
|
530
|
+
</xsl:call-template>
|
|
531
|
+
</xsl:variable>
|
|
532
|
+
<xsl:value-of select="string-length($pString) - string-length(substring-before($vRevString,$vRevSearch))"/>
|
|
533
|
+
</xsl:when>
|
|
534
|
+
<xsl:otherwise>0</xsl:otherwise>
|
|
535
|
+
</xsl:choose>
|
|
536
|
+
</xsl:template>
|
|
537
|
+
|
|
538
|
+
<xsl:template name="tReverseString">
|
|
539
|
+
<xsl:param name="pString"/>
|
|
540
|
+
<xsl:variable name="vLength" select="string-length($pString)"/>
|
|
541
|
+
<xsl:choose>
|
|
542
|
+
<xsl:when test="$vLength < 2"><xsl:value-of select="$pString"/></xsl:when>
|
|
543
|
+
<xsl:when test="$vLength = 2">
|
|
544
|
+
<xsl:value-of select="concat(substring($pString,2,1),substring($pString,1,1))"/>
|
|
545
|
+
</xsl:when>
|
|
546
|
+
<xsl:otherwise>
|
|
547
|
+
<xsl:variable name="vMid" select="floor($vLength div 2)"/>
|
|
548
|
+
<xsl:variable name="vHalf1">
|
|
549
|
+
<xsl:call-template name="tReverseString">
|
|
550
|
+
<xsl:with-param name="pString" select="substring($pString,1,$vMid)"/>
|
|
551
|
+
</xsl:call-template>
|
|
552
|
+
</xsl:variable>
|
|
553
|
+
<xsl:variable name="vHalf2">
|
|
554
|
+
<xsl:call-template name="tReverseString">
|
|
555
|
+
<xsl:with-param name="pString" select="substring($pString,$vMid+1)"/>
|
|
556
|
+
</xsl:call-template>
|
|
557
|
+
</xsl:variable>
|
|
558
|
+
<xsl:value-of select="concat($vHalf2,$vHalf1)"/>
|
|
559
|
+
</xsl:otherwise>
|
|
560
|
+
</xsl:choose>
|
|
561
|
+
</xsl:template>
|
|
562
|
+
|
|
563
|
+
<!-- Let's say there are initials in the string if we find an uppercase letter
|
|
564
|
+
followed by "." and preceded by [ .] -->
|
|
565
|
+
<xsl:template name="tFindInitials">
|
|
566
|
+
<xsl:param name="pString"/>
|
|
567
|
+
<xsl:variable name="vLength" select="string-length($pString)"/>
|
|
568
|
+
<xsl:choose>
|
|
569
|
+
<xsl:when test="contains($upper,substring($pString,$vLength,1)) and
|
|
570
|
+
contains(' .',substring($pString,$vLength - 1,1))">
|
|
571
|
+
<xsl:value-of select="true()"/>
|
|
572
|
+
</xsl:when>
|
|
573
|
+
<xsl:when test="contains($pString,'.')">
|
|
574
|
+
<xsl:variable name="vLastPeriod">
|
|
575
|
+
<xsl:call-template name="tLastIndex">
|
|
576
|
+
<xsl:with-param name="pString" select="$pString"/>
|
|
577
|
+
<xsl:with-param name="pSearch" select="'.'"/>
|
|
578
|
+
</xsl:call-template>
|
|
579
|
+
</xsl:variable>
|
|
580
|
+
<xsl:call-template name="tFindInitials">
|
|
581
|
+
<xsl:with-param name="pString" select="substring($pString,1,$vLastPeriod - 1)"/>
|
|
582
|
+
</xsl:call-template>
|
|
583
|
+
</xsl:when>
|
|
584
|
+
<xsl:otherwise>
|
|
585
|
+
<xsl:value-of select="false()"/>
|
|
586
|
+
</xsl:otherwise>
|
|
587
|
+
</xsl:choose>
|
|
588
|
+
</xsl:template>
|
|
589
|
+
|
|
590
|
+
<xsl:template name="tBalanceBrackets">
|
|
591
|
+
<xsl:param name="pString"/>
|
|
592
|
+
<xsl:param name="pAddBrackets" select="false()"/>
|
|
593
|
+
<xsl:choose>
|
|
594
|
+
<xsl:when test="contains($pString,'[') and not(contains(substring-after($pString,'['),']'))">
|
|
595
|
+
<xsl:value-of select="concat($pString,']')"/>
|
|
596
|
+
</xsl:when>
|
|
597
|
+
<xsl:when test="contains($pString,']') and not(contains(substring-before($pString,']'),'['))">
|
|
598
|
+
<xsl:value-of select="concat('[',$pString)"/>
|
|
599
|
+
</xsl:when>
|
|
600
|
+
<xsl:when test="$pAddBrackets">
|
|
601
|
+
<xsl:value-of select="concat('[',$pString,']')"/>
|
|
602
|
+
</xsl:when>
|
|
603
|
+
<xsl:otherwise>
|
|
604
|
+
<xsl:value-of select="$pString"/>
|
|
605
|
+
</xsl:otherwise>
|
|
606
|
+
</xsl:choose>
|
|
607
|
+
</xsl:template>
|
|
608
|
+
|
|
609
|
+
<!--
|
|
610
|
+
generate a recordid base from user config
|
|
611
|
+
-->
|
|
612
|
+
<xsl:template match="marc:record" mode="recordid">
|
|
613
|
+
<xsl:param name="baseuri" select="'http://example.org/'"/>
|
|
614
|
+
<xsl:param name="idfield" select="'001'"/>
|
|
615
|
+
<xsl:param name="recordno"/>
|
|
616
|
+
<xsl:variable name="tag" select="substring($idfield,1,3)"/>
|
|
617
|
+
<xsl:variable name="subfield">
|
|
618
|
+
<xsl:choose>
|
|
619
|
+
<xsl:when test="substring($idfield,4,1)">
|
|
620
|
+
<xsl:value-of select="substring($idfield,4,1)"/>
|
|
621
|
+
</xsl:when>
|
|
622
|
+
<xsl:otherwise>a</xsl:otherwise>
|
|
623
|
+
</xsl:choose>
|
|
624
|
+
</xsl:variable>
|
|
625
|
+
<xsl:variable name="recordid">
|
|
626
|
+
<xsl:choose>
|
|
627
|
+
<xsl:when test="$tag < 10">
|
|
628
|
+
<xsl:if test="count(marc:controlfield[@tag=$tag]) = 1">
|
|
629
|
+
<xsl:call-template name="url-encode">
|
|
630
|
+
<xsl:with-param name="str" select="normalize-space(marc:controlfield[@tag=$tag])"/>
|
|
631
|
+
</xsl:call-template>
|
|
632
|
+
</xsl:if>
|
|
633
|
+
</xsl:when>
|
|
634
|
+
<xsl:otherwise>
|
|
635
|
+
<xsl:if test="count(marc:datafield[@tag=$tag]/marc:subfield[@code=$subfield]) = 1">
|
|
636
|
+
<xsl:call-template name="url-encode">
|
|
637
|
+
<xsl:with-param name="str" select="normalize-space(marc:datafield[@tag=$tag]/marc:subfield[@code=$subfield])"/>
|
|
638
|
+
</xsl:call-template>
|
|
639
|
+
</xsl:if>
|
|
640
|
+
</xsl:otherwise>
|
|
641
|
+
</xsl:choose>
|
|
642
|
+
</xsl:variable>
|
|
643
|
+
<xsl:choose>
|
|
644
|
+
<xsl:when test="$recordid != ''">
|
|
645
|
+
<xsl:value-of select="$baseuri"/><xsl:value-of select="$recordid"/>
|
|
646
|
+
</xsl:when>
|
|
647
|
+
<xsl:otherwise>
|
|
648
|
+
<xsl:message terminate="no">
|
|
649
|
+
<xsl:text>WARNING: Unable to determine record ID for record </xsl:text><xsl:value-of select="$recordno"/><xsl:text>. Using generated ID.</xsl:text>
|
|
650
|
+
</xsl:message>
|
|
651
|
+
<xsl:value-of select="$baseuri"/><xsl:value-of select="generate-id(.)"/>
|
|
652
|
+
</xsl:otherwise>
|
|
653
|
+
</xsl:choose>
|
|
654
|
+
</xsl:template>
|
|
655
|
+
|
|
656
|
+
<!--
|
|
657
|
+
create a space delimited label
|
|
658
|
+
need to trim off the trailing space to use
|
|
659
|
+
-->
|
|
660
|
+
<xsl:template match="*" mode="concat-nodes-space">
|
|
661
|
+
<xsl:value-of select="."/><xsl:text> </xsl:text>
|
|
662
|
+
</xsl:template>
|
|
663
|
+
|
|
664
|
+
<!--
|
|
665
|
+
create a label with parameterized delimiter for a nodeset
|
|
666
|
+
only add delimiter when there is no punctuation
|
|
667
|
+
used in creating bf:provisionActivityStatement
|
|
668
|
+
-->
|
|
669
|
+
<xsl:template match="*" mode="concat-nodes-delimited">
|
|
670
|
+
<xsl:param name="pDelimiter" select="';'"/>
|
|
671
|
+
<xsl:param name="punctuation">
|
|
672
|
+
<xsl:text>.:,;/</xsl:text>
|
|
673
|
+
</xsl:param>
|
|
674
|
+
<xsl:variable name="vValue" select="normalize-space(.)"/>
|
|
675
|
+
<xsl:choose>
|
|
676
|
+
<xsl:when test="position() = last()">
|
|
677
|
+
<xsl:value-of select="$vValue"/>
|
|
678
|
+
</xsl:when>
|
|
679
|
+
<xsl:otherwise>
|
|
680
|
+
<xsl:choose>
|
|
681
|
+
<xsl:when test="$vValue=''"/>
|
|
682
|
+
<xsl:when test="contains($punctuation, substring($vValue,string-length($vValue),1))">
|
|
683
|
+
<xsl:value-of select="$vValue"/><xsl:text> </xsl:text>
|
|
684
|
+
</xsl:when>
|
|
685
|
+
<xsl:otherwise>
|
|
686
|
+
<xsl:value-of select="$vValue"/><xsl:value-of select="$pDelimiter"/><xsl:text> </xsl:text>
|
|
687
|
+
</xsl:otherwise>
|
|
688
|
+
</xsl:choose>
|
|
689
|
+
</xsl:otherwise>
|
|
690
|
+
</xsl:choose>
|
|
691
|
+
</xsl:template>
|
|
692
|
+
|
|
693
|
+
<!--
|
|
694
|
+
generate a marcKey for the subfields of a marc:datafield
|
|
695
|
+
of the form $[code][text]$[code][text] etc.
|
|
696
|
+
-->
|
|
697
|
+
<xsl:template match="marc:datafield" mode="marcKey">
|
|
698
|
+
<xsl:variable name="marckey">
|
|
699
|
+
<xsl:apply-templates select="marc:subfield" mode="marcKey"/>
|
|
700
|
+
</xsl:variable>
|
|
701
|
+
<xsl:value-of select="concat(@tag,@ind1,@ind2,normalize-space($marckey))" />
|
|
702
|
+
</xsl:template>
|
|
703
|
+
<xsl:template match="marc:subfield" mode="marcKey">
|
|
704
|
+
<xsl:text>$</xsl:text><xsl:value-of select="@code"/><xsl:value-of select="normalize-space(.)"/>
|
|
705
|
+
</xsl:template>
|
|
706
|
+
|
|
707
|
+
<!--
|
|
708
|
+
convert "u" or "U" to "X" for dates
|
|
709
|
+
-->
|
|
710
|
+
<xsl:template name="u2x">
|
|
711
|
+
<xsl:param name="dateString"/>
|
|
712
|
+
<xsl:choose>
|
|
713
|
+
<xsl:when test="contains($dateString,'u')">
|
|
714
|
+
<xsl:call-template name="u2x">
|
|
715
|
+
<xsl:with-param name="dateString" select="concat(substring-before($dateString,'u'),'X',substring-after($dateString,'u'))"/>
|
|
716
|
+
</xsl:call-template>
|
|
717
|
+
</xsl:when>
|
|
718
|
+
<xsl:when test="contains($dateString,'U')">
|
|
719
|
+
<xsl:call-template name="u2x">
|
|
720
|
+
<xsl:with-param name="dateString" select="concat(substring-before($dateString,'U'),'X',substring-after($dateString,'U'))"/>
|
|
721
|
+
</xsl:call-template>
|
|
722
|
+
</xsl:when>
|
|
723
|
+
<xsl:otherwise><xsl:value-of select="$dateString"/></xsl:otherwise>
|
|
724
|
+
</xsl:choose>
|
|
725
|
+
</xsl:template>
|
|
726
|
+
|
|
727
|
+
<!--
|
|
728
|
+
convert a date string as from the 033/263 to an EDTF date
|
|
729
|
+
(https://www.loc.gov/standards/datetime/pre-submission.html)
|
|
730
|
+
with one difference - use 'X' for unspecified digits
|
|
731
|
+
-->
|
|
732
|
+
<xsl:template name="edtfFormat">
|
|
733
|
+
<xsl:param name="pDateString"/>
|
|
734
|
+
<!-- convert '-' to 'X' -->
|
|
735
|
+
<xsl:choose>
|
|
736
|
+
<xsl:when test="contains(substring($pDateString,1,12),'-')">
|
|
737
|
+
<xsl:call-template name="edtfFormat">
|
|
738
|
+
<xsl:with-param name="pDateString" select="concat(substring-before($pDateString,'-'),'X',substring-after($pDateString,'-'))"/>
|
|
739
|
+
</xsl:call-template>
|
|
740
|
+
</xsl:when>
|
|
741
|
+
<xsl:otherwise>
|
|
742
|
+
<xsl:variable name="vDatePart">
|
|
743
|
+
<xsl:choose>
|
|
744
|
+
<xsl:when test="substring($pDateString,7,2) != ''">
|
|
745
|
+
<xsl:value-of select="concat(substring($pDateString,1,4),'-',substring($pDateString,5,2),'-',substring($pDateString,7,2))"/>
|
|
746
|
+
</xsl:when>
|
|
747
|
+
<xsl:otherwise>
|
|
748
|
+
<xsl:value-of select="concat(substring($pDateString,1,4),'-',substring($pDateString,5,2))"/>
|
|
749
|
+
</xsl:otherwise>
|
|
750
|
+
</xsl:choose>
|
|
751
|
+
</xsl:variable>
|
|
752
|
+
<xsl:variable name="vTimePart">
|
|
753
|
+
<xsl:if test="substring($pDateString,9,4) != ''">
|
|
754
|
+
<xsl:value-of select="concat('T',substring($pDateString,9,2),':',substring($pDateString,11,2),':00')"/>
|
|
755
|
+
</xsl:if>
|
|
756
|
+
</xsl:variable>
|
|
757
|
+
<xsl:variable name="vTimeDiff">
|
|
758
|
+
<xsl:if test="substring($pDateString,13,5) != ''">
|
|
759
|
+
<xsl:value-of select="concat(substring($pDateString,13,3),':',substring($pDateString,16,2))"/>
|
|
760
|
+
</xsl:if>
|
|
761
|
+
</xsl:variable>
|
|
762
|
+
<xsl:value-of select="concat($vDatePart,$vTimePart,$vTimeDiff)"/>
|
|
763
|
+
</xsl:otherwise>
|
|
764
|
+
</xsl:choose>
|
|
765
|
+
</xsl:template>
|
|
766
|
+
|
|
767
|
+
<!--
|
|
768
|
+
Take a date in the format specified in 046 $j,$k,$l,$m,$n,$o,$p
|
|
769
|
+
Transform to EDTF-conformant date (yyyy-mm-Thh:mm:ss.f with no
|
|
770
|
+
timezone)
|
|
771
|
+
-->
|
|
772
|
+
<xsl:template name="tMarcToEdtf">
|
|
773
|
+
<xsl:param name="pDateString"/>
|
|
774
|
+
<xsl:variable name="vYear"><xsl:value-of select="substring($pDateString,1,4)"/></xsl:variable>
|
|
775
|
+
<xsl:variable name="vMonth"><xsl:value-of select="substring($pDateString,5,2)"/></xsl:variable>
|
|
776
|
+
<xsl:variable name="vDay"><xsl:value-of select="substring($pDateString,7,2)"/></xsl:variable>
|
|
777
|
+
<xsl:variable name="vHour"><xsl:value-of select="substring($pDateString,9,2)"/></xsl:variable>
|
|
778
|
+
<xsl:variable name="vMinute"><xsl:value-of select="substring($pDateString,11,2)"/></xsl:variable>
|
|
779
|
+
<xsl:variable name="vSecond"><xsl:value-of select="substring($pDateString,13)"/></xsl:variable>
|
|
780
|
+
<xsl:choose>
|
|
781
|
+
<xsl:when test="$vSecond != ''">
|
|
782
|
+
<xsl:value-of select="concat($vYear,'-',$vMonth,'-',$vDay,'T',$vHour,':',$vMinute,':',$vSecond)"/>
|
|
783
|
+
</xsl:when>
|
|
784
|
+
<xsl:when test="$vMinute != ''">
|
|
785
|
+
<xsl:value-of select="concat($vYear,'-',$vMonth,'-',$vDay,'T',$vHour,':',$vMinute)"/>
|
|
786
|
+
</xsl:when>
|
|
787
|
+
<xsl:when test="$vHour != ''">
|
|
788
|
+
<xsl:value-of select="concat($vYear,'-',$vMonth,'-',$vDay,'T',$vHour)"/>
|
|
789
|
+
</xsl:when>
|
|
790
|
+
<xsl:when test="$vDay != ''">
|
|
791
|
+
<xsl:value-of select="concat($vYear,'-',$vMonth,'-',$vDay)"/>
|
|
792
|
+
</xsl:when>
|
|
793
|
+
<xsl:when test="$vMonth != ''">
|
|
794
|
+
<xsl:value-of select="concat($vYear,'-',$vMonth)"/>
|
|
795
|
+
</xsl:when>
|
|
796
|
+
<xsl:otherwise><xsl:value-of select="$vYear"/></xsl:otherwise>
|
|
797
|
+
</xsl:choose>
|
|
798
|
+
</xsl:template>
|
|
799
|
+
|
|
800
|
+
<!--
|
|
801
|
+
generate a property with a blank node Resource, and an rdfs:label
|
|
802
|
+
process $3 and $2, if necessary
|
|
803
|
+
Inspired by processing 340, may be useful elsewhere (actually
|
|
804
|
+
not used by 340, but by other 3XX fields)
|
|
805
|
+
-->
|
|
806
|
+
|
|
807
|
+
<xsl:template match="marc:subfield" mode="generateProperty">
|
|
808
|
+
<xsl:param name="serialization" select="'rdfxml'"/>
|
|
809
|
+
<xsl:param name="pInstanceType" />
|
|
810
|
+
<xsl:param name="pProp"/>
|
|
811
|
+
<xsl:param name="pResource"/>
|
|
812
|
+
<xsl:param name="pTarget"/>
|
|
813
|
+
<xsl:param name="pObjStringProp" select="'rdfs:label'"/>
|
|
814
|
+
<xsl:param name="pLabel"/>
|
|
815
|
+
<xsl:param name="pProcess"/>
|
|
816
|
+
<xsl:param name="pPunctuation" select="'.:;,/='"/>
|
|
817
|
+
<xsl:param name="pVocabStem"/>
|
|
818
|
+
<xsl:variable name="vXmlLang"><xsl:apply-templates select="../marc:datafield" mode="xmllang"/></xsl:variable>
|
|
819
|
+
<xsl:variable name="vCurrentNode" select="generate-id(.)"/>
|
|
820
|
+
<xsl:variable name="vLabel">
|
|
821
|
+
<xsl:choose>
|
|
822
|
+
<xsl:when test="$pLabel != ''"><xsl:value-of select="$pLabel"/></xsl:when>
|
|
823
|
+
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
|
|
824
|
+
</xsl:choose>
|
|
825
|
+
</xsl:variable>
|
|
826
|
+
<xsl:choose>
|
|
827
|
+
<xsl:when test="$serialization = 'rdfxml'">
|
|
828
|
+
<xsl:element name="{$pProp}">
|
|
829
|
+
<xsl:element name="{$pResource}">
|
|
830
|
+
<xsl:if test="$pTarget != ''">
|
|
831
|
+
<xsl:attribute name="rdf:about"><xsl:value-of select="$pTarget"/></xsl:attribute>
|
|
832
|
+
</xsl:if>
|
|
833
|
+
<xsl:element name="{$pObjStringProp}">
|
|
834
|
+
<xsl:if test="$vXmlLang != ''">
|
|
835
|
+
<xsl:attribute name="xml:lang"><xsl:value-of select="$vXmlLang"/></xsl:attribute>
|
|
836
|
+
</xsl:if>
|
|
837
|
+
<xsl:choose>
|
|
838
|
+
<xsl:when test="$pProcess='chopPunctuation'">
|
|
839
|
+
<xsl:call-template name="tChopPunct">
|
|
840
|
+
<xsl:with-param name="pString"><xsl:value-of select="$vLabel"/></xsl:with-param>
|
|
841
|
+
<xsl:with-param name="pEndPunct" select="$pPunctuation"/>
|
|
842
|
+
</xsl:call-template>
|
|
843
|
+
</xsl:when>
|
|
844
|
+
<xsl:when test="$pProcess='chopParens'">
|
|
845
|
+
<xsl:call-template name="tChopPunct">
|
|
846
|
+
<xsl:with-param name="pString"><xsl:value-of select="$vLabel"/></xsl:with-param>
|
|
847
|
+
<xsl:with-param name="pEndPunct" select="$pPunctuation"/>
|
|
848
|
+
<xsl:with-param name="pChopParens" select="true()"/>
|
|
849
|
+
</xsl:call-template>
|
|
850
|
+
</xsl:when>
|
|
851
|
+
<xsl:otherwise><xsl:value-of select="$vLabel"/></xsl:otherwise>
|
|
852
|
+
</xsl:choose>
|
|
853
|
+
</xsl:element>
|
|
854
|
+
<!--
|
|
855
|
+
<xsl:apply-templates select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode]" mode="subfield0orw">
|
|
856
|
+
<xsl:with-param name="serialization" select="$serialization"/>
|
|
857
|
+
</xsl:apply-templates>
|
|
858
|
+
-->
|
|
859
|
+
<xsl:for-each select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and contains(text(),'://')]">
|
|
860
|
+
<xsl:variable name="the0">
|
|
861
|
+
<xsl:choose>
|
|
862
|
+
<xsl:when test="starts-with(.,'(uri)')">
|
|
863
|
+
<xsl:value-of select="substring-after(.,'(uri)')"/>
|
|
864
|
+
</xsl:when>
|
|
865
|
+
<xsl:otherwise>
|
|
866
|
+
<xsl:value-of select="."/>
|
|
867
|
+
</xsl:otherwise>
|
|
868
|
+
</xsl:choose>
|
|
869
|
+
</xsl:variable>
|
|
870
|
+
<xsl:if test="$the0 != $pTarget">
|
|
871
|
+
<madsrdf:hasRelatedAuthority>
|
|
872
|
+
<xsl:attribute name="rdf:resource">
|
|
873
|
+
<xsl:value-of select="$the0"/>
|
|
874
|
+
</xsl:attribute>
|
|
875
|
+
</madsrdf:hasRelatedAuthority>
|
|
876
|
+
</xsl:if>
|
|
877
|
+
</xsl:for-each>
|
|
878
|
+
<xsl:apply-templates select="following-sibling::marc:subfield[@code='0' and generate-id(preceding-sibling::marc:subfield[@code != '0'][1])=$vCurrentNode and not(contains(text(),'://'))]" mode="subfield0orw">
|
|
879
|
+
<xsl:with-param name="serialization" select="$serialization"/>
|
|
880
|
+
</xsl:apply-templates>
|
|
881
|
+
<xsl:if test="$pInstanceType != 'SecondaryInstance'">
|
|
882
|
+
<xsl:apply-templates select="../marc:subfield[@code='3']" mode="subfield3">
|
|
883
|
+
<xsl:with-param name="serialization" select="$serialization"/>
|
|
884
|
+
</xsl:apply-templates>
|
|
885
|
+
</xsl:if>
|
|
886
|
+
<xsl:apply-templates select="../marc:subfield[@code='2']" mode="subfield2">
|
|
887
|
+
<xsl:with-param name="serialization" select="$serialization"/>
|
|
888
|
+
<xsl:with-param name="pVocabStem" select="$pVocabStem"/>
|
|
889
|
+
</xsl:apply-templates>
|
|
890
|
+
</xsl:element>
|
|
891
|
+
</xsl:element>
|
|
892
|
+
</xsl:when>
|
|
893
|
+
</xsl:choose>
|
|
894
|
+
</xsl:template>
|
|
895
|
+
|
|
896
|
+
<!-- get the tag ord of a datafield within a marc:record -->
|
|
897
|
+
<xsl:template match="marc:datafield" mode="tagord">
|
|
898
|
+
<xsl:variable name="vId" select="generate-id(.)"/>
|
|
899
|
+
<xsl:for-each select="../marc:leader | ../marc:controlfield | ../marc:datafield">
|
|
900
|
+
<xsl:if test="generate-id(.)=$vId"><xsl:value-of select="position()"/></xsl:if>
|
|
901
|
+
</xsl:for-each>
|
|
902
|
+
</xsl:template>
|
|
903
|
+
|
|
904
|
+
<!--
|
|
905
|
+
URL encode a string, ASCII only
|
|
906
|
+
based on https://skew.org/xml/stylesheets/url-encode/url-encode.xsl
|
|
907
|
+
-->
|
|
908
|
+
<xsl:template name="url-encode">
|
|
909
|
+
<xsl:param name="str"/>
|
|
910
|
+
<xsl:variable name="ascii"> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:variable>
|
|
911
|
+
<xsl:variable name="safe">!'()*-.:/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:variable>
|
|
912
|
+
<xsl:variable name="hex" >0123456789ABCDEF</xsl:variable>
|
|
913
|
+
<xsl:if test="$str">
|
|
914
|
+
<xsl:variable name="first-char" select="substring($str,1,1)"/>
|
|
915
|
+
<xsl:choose>
|
|
916
|
+
<xsl:when test="contains($safe,$first-char)">
|
|
917
|
+
<xsl:value-of select="$first-char"/>
|
|
918
|
+
</xsl:when>
|
|
919
|
+
<xsl:otherwise>
|
|
920
|
+
<xsl:variable name="codepoint">
|
|
921
|
+
<xsl:choose>
|
|
922
|
+
<xsl:when test="contains($ascii,$first-char)">
|
|
923
|
+
<xsl:value-of select="string-length(substring-before($ascii,$first-char)) + 32"/>
|
|
924
|
+
</xsl:when>
|
|
925
|
+
<xsl:otherwise>
|
|
926
|
+
<xsl:message terminate="no">Warning: string contains a character that is out of range! Substituting "?".</xsl:message>
|
|
927
|
+
<xsl:message terminate="no"><xsl:value-of select="concat('See record with 001: ', ancestor-or-self::marc:record/marc:controlfield[@tag='001'])"/></xsl:message>
|
|
928
|
+
<xsl:text>63</xsl:text>
|
|
929
|
+
</xsl:otherwise>
|
|
930
|
+
</xsl:choose>
|
|
931
|
+
</xsl:variable>
|
|
932
|
+
<xsl:variable name="hex-digit1" select="substring($hex,floor($codepoint div 16) + 1,1)"/>
|
|
933
|
+
<xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/>
|
|
934
|
+
<xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
|
|
935
|
+
</xsl:otherwise>
|
|
936
|
+
</xsl:choose>
|
|
937
|
+
<xsl:if test="string-length($str) > 1">
|
|
938
|
+
<xsl:call-template name="url-encode">
|
|
939
|
+
<xsl:with-param name="str" select="substring($str,2)"/>
|
|
940
|
+
</xsl:call-template>
|
|
941
|
+
</xsl:if>
|
|
942
|
+
</xsl:if>
|
|
943
|
+
</xsl:template>
|
|
944
|
+
|
|
945
|
+
<!-- Return a normalized code suitable for constructing a URI -->
|
|
946
|
+
<xsl:template name="tNormalizeCode">
|
|
947
|
+
<xsl:param name="pCode"/>
|
|
948
|
+
<xsl:param name="pStripPunct" select="false()"/>
|
|
949
|
+
<xsl:variable name="vCode">
|
|
950
|
+
<xsl:choose>
|
|
951
|
+
<!-- well, not all punctuation (e.g. quotes), but probably enough -->
|
|
952
|
+
<xsl:when test="$pStripPunct">
|
|
953
|
+
<xsl:value-of select="translate($pCode,'.?!,;:-/\()[]{} ','')"/>
|
|
954
|
+
</xsl:when>
|
|
955
|
+
<xsl:otherwise><xsl:value-of select="$pCode"/></xsl:otherwise>
|
|
956
|
+
</xsl:choose>
|
|
957
|
+
</xsl:variable>
|
|
958
|
+
<xsl:call-template name="url-encode">
|
|
959
|
+
<xsl:with-param name="str" select="translate(normalize-space($vCode),$upper,$lower)"/>
|
|
960
|
+
</xsl:call-template>
|
|
961
|
+
</xsl:template>
|
|
962
|
+
|
|
963
|
+
</xsl:stylesheet>
|