|
Line 0
Link Here
|
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<xsl:stylesheet version="1.0" |
| 3 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
| 4 |
xmlns:dcterms="http://purl.org/dc/terms/1.1" |
| 5 |
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" |
| 6 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 7 |
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ |
| 8 |
http://www.openarchives.org/OAI/2.0/oai_dc.xsd" |
| 9 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 10 |
xmlns="http://www.loc.gov/MARC21/slim" exclude-result-prefixes="dc dcterms oai_dc"> |
| 11 |
|
| 12 |
<xsl:import href="MARC21slimUtils.xsl"/> |
| 13 |
<xsl:output method="xml" encoding="UTF-8" indent="yes"/> |
| 14 |
|
| 15 |
|
| 16 |
<xsl:template match="/"> |
| 17 |
<collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" > |
| 18 |
<xsl:apply-templates /> |
| 19 |
</collection> |
| 20 |
</xsl:template> |
| 21 |
|
| 22 |
<xsl:template name="OAI-PMH"> |
| 23 |
<xsl:for-each select = "ListRecords/record/metadata/oai_dc:dc"> |
| 24 |
<xsl:apply-templates /> |
| 25 |
</xsl:for-each> |
| 26 |
<xsl:for-each select = "GetRecord/record/metadata/oai_dc:dc"> |
| 27 |
<xsl:apply-templates /> |
| 28 |
</xsl:for-each> |
| 29 |
</xsl:template> |
| 30 |
|
| 31 |
<xsl:template match="text()" /> |
| 32 |
<xsl:template match="oai_dc:dc"> |
| 33 |
<record> |
| 34 |
<xsl:element name="leader"> |
| 35 |
<xsl:variable name="type" select="dc:type"/> |
| 36 |
<xsl:variable name="leader06"> |
| 37 |
<xsl:choose> |
| 38 |
<xsl:when test="$type='collection'">p</xsl:when> |
| 39 |
<xsl:when test="$type='dataset'">m</xsl:when> |
| 40 |
<xsl:when test="$type='event'">r</xsl:when> |
| 41 |
<xsl:when test="$type='image'">k</xsl:when> |
| 42 |
<xsl:when test="$type='interactive resource'">m</xsl:when> |
| 43 |
<xsl:when test="$type='service'">m</xsl:when> |
| 44 |
<xsl:when test="$type='software'">m</xsl:when> |
| 45 |
<xsl:when test="$type='sound'">i</xsl:when> |
| 46 |
<xsl:when test="$type='text'">a</xsl:when> |
| 47 |
<xsl:otherwise>a</xsl:otherwise> |
| 48 |
</xsl:choose> |
| 49 |
</xsl:variable> |
| 50 |
<xsl:variable name="leader07"> |
| 51 |
<xsl:choose> |
| 52 |
<xsl:when test="$type='collection'">c</xsl:when> |
| 53 |
<xsl:otherwise>m</xsl:otherwise> |
| 54 |
</xsl:choose> |
| 55 |
</xsl:variable> |
| 56 |
<xsl:value-of select="concat(' ',$leader06,$leader07,' 3u ')"/> |
| 57 |
</xsl:element> |
| 58 |
|
| 59 |
<datafield tag="042" ind1=" " ind2=" "> |
| 60 |
<subfield code="a">dc</subfield> |
| 61 |
</datafield> |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
<xsl:for-each select="dc:creator"> |
| 66 |
<xsl:choose> |
| 67 |
<xsl:when test="(.!='') and (position()=1)"> |
| 68 |
<xsl:call-template name="persname_template"> |
| 69 |
<xsl:with-param name="string" select="." /> |
| 70 |
<xsl:with-param name="field" select="'100'" /> |
| 71 |
<xsl:with-param name="ind1" select = "'1'" /> |
| 72 |
<xsl:with-param name="ind2" select = "'0'" /> |
| 73 |
<xsl:with-param name="type" select="'author'" /> |
| 74 |
</xsl:call-template> |
| 75 |
</xsl:when> |
| 76 |
<xsl:otherwise> |
| 77 |
<xsl:if test=".!=''"> |
| 78 |
<xsl:call-template name="persname_template"> |
| 79 |
<xsl:with-param name="string" select="." /> |
| 80 |
<xsl:with-param name="field" select="'700'" /> |
| 81 |
<xsl:with-param name="ind1" select = "'1'" /> |
| 82 |
<xsl:with-param name="ind2" select = "'0'" /> |
| 83 |
<xsl:with-param name="type" select="'author'" /> |
| 84 |
</xsl:call-template> |
| 85 |
</xsl:if> |
| 86 |
</xsl:otherwise> |
| 87 |
</xsl:choose> |
| 88 |
</xsl:for-each> |
| 89 |
|
| 90 |
|
| 91 |
<xsl:for-each select="dc:title[1]"> |
| 92 |
<datafield tag="245" ind1="0" ind2="0"> |
| 93 |
<subfield code="a"> |
| 94 |
<xsl:value-of select="."/> |
| 95 |
</subfield> |
| 96 |
</datafield> |
| 97 |
</xsl:for-each> |
| 98 |
|
| 99 |
<xsl:for-each select="dc:title[position()>1]"> |
| 100 |
<xsl:if test=".!=''"> |
| 101 |
<datafield tag="246" ind1="3" ind2="3"> |
| 102 |
<subfield code="a"> |
| 103 |
<xsl:value-of select="."/> |
| 104 |
</subfield> |
| 105 |
</datafield> |
| 106 |
</xsl:if> |
| 107 |
</xsl:for-each> |
| 108 |
|
| 109 |
<xsl:choose> |
| 110 |
<xsl:when test="dc:publisher"> |
| 111 |
<xsl:if test="translate(dc:publisher/.,'.,:;','')!=''"> |
| 112 |
<datafield tag="260" ind1=" " ind2=" "> |
| 113 |
<xsl:choose> |
| 114 |
<xsl:when test="dc:date"> |
| 115 |
<subfield code="b"><xsl:value-of select="dc:publisher[1]"/>, </subfield> |
| 116 |
<xsl:if test="translate(dc:date[1]/., '.,:;','')!=''"> |
| 117 |
<subfield code="c"><xsl:value-of select="dc:date[1]" />.</subfield> |
| 118 |
</xsl:if> |
| 119 |
</xsl:when> |
| 120 |
<xsl:otherwise> |
| 121 |
<subfield code="b"><xsl:value-of select="dc:publisher[1]"/>.</subfield> |
| 122 |
</xsl:otherwise> |
| 123 |
</xsl:choose> |
| 124 |
</datafield> |
| 125 |
</xsl:if> |
| 126 |
</xsl:when> |
| 127 |
<xsl:otherwise> |
| 128 |
<xsl:if test="translate(dc:date[1],'.,:;','')!=''"> |
| 129 |
<datafield tag="260" ind1=" " ind2=" "> |
| 130 |
<subfield code="c"><xsl:value-of select="dc:date[1]" />.</subfield> |
| 131 |
</datafield> |
| 132 |
</xsl:if> |
| 133 |
</xsl:otherwise> |
| 134 |
</xsl:choose> |
| 135 |
|
| 136 |
<xsl:for-each select="dc:coverage"> |
| 137 |
<xsl:choose> |
| 138 |
<xsl:when test="translate(., '0123456789-.?','')=''"> |
| 139 |
<!--Likely;this is a date--> |
| 140 |
<datafield tag="500" ind1=" " ind2=" "> |
| 141 |
<subfield code="a"><xsl:value-of select="."/></subfield> |
| 142 |
</datafield> |
| 143 |
</xsl:when> |
| 144 |
<xsl:otherwise> |
| 145 |
<!--likely a geographic subject, we will print this later--> |
| 146 |
</xsl:otherwise> |
| 147 |
</xsl:choose> |
| 148 |
</xsl:for-each> |
| 149 |
|
| 150 |
<xsl:for-each select="dc:identifier"> |
| 151 |
<xsl:if test="position()!=last()"> |
| 152 |
<datafield tag="500" ind1=" " ind2=" "> |
| 153 |
<subfield code="a"><xsl:value-of select="." /></subfield> |
| 154 |
</datafield> |
| 155 |
</xsl:if> |
| 156 |
</xsl:for-each> |
| 157 |
|
| 158 |
<xsl:for-each select="dc:description"> |
| 159 |
<datafield tag="520" ind1=" " ind2=" "> |
| 160 |
<subfield code="a"> |
| 161 |
<xsl:value-of select="normalize-space(.)"/> |
| 162 |
</subfield> |
| 163 |
</datafield> |
| 164 |
</xsl:for-each> |
| 165 |
|
| 166 |
|
| 167 |
<xsl:for-each select="dc:rights"> |
| 168 |
<datafield tag="540" ind1=" " ind2=" "> |
| 169 |
<subfield code="a"> |
| 170 |
<xsl:value-of select="."/> |
| 171 |
</subfield> |
| 172 |
</datafield> |
| 173 |
</xsl:for-each> |
| 174 |
|
| 175 |
|
| 176 |
<xsl:for-each select="dc:language"> |
| 177 |
<datafield tag="546" ind1=" " ind2=" "> |
| 178 |
<subfield code="a"> |
| 179 |
<xsl:value-of select="."/> |
| 180 |
</subfield> |
| 181 |
</datafield> |
| 182 |
</xsl:for-each> |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
<xsl:for-each select="dc:subject"> |
| 187 |
<datafield tag="690" ind1=" " ind2=" "> |
| 188 |
<subfield code="a"> |
| 189 |
<xsl:value-of select="."/> |
| 190 |
</subfield> |
| 191 |
</datafield> |
| 192 |
</xsl:for-each> |
| 193 |
|
| 194 |
<xsl:for-each select="dc:coverage"> |
| 195 |
<xsl:choose> |
| 196 |
<xsl:when test="translate(., '0123456789-.?','')=''"> |
| 197 |
<!--Likely; this is a date--> |
| 198 |
</xsl:when> |
| 199 |
<xsl:otherwise> |
| 200 |
<!--likely a geographic subject--> |
| 201 |
<datafield tag="691" ind1=" " ind2=" "> |
| 202 |
<subfield code="a"><xsl:value-of select="." /></subfield> |
| 203 |
</datafield> |
| 204 |
</xsl:otherwise> |
| 205 |
</xsl:choose> |
| 206 |
</xsl:for-each> |
| 207 |
|
| 208 |
|
| 209 |
<xsl:for-each select="dc:type"> |
| 210 |
<datafield tag="655" ind1="7" ind2=" "> |
| 211 |
<subfield code="a"> |
| 212 |
<xsl:value-of select="."/> |
| 213 |
</subfield> |
| 214 |
<subfield code="2">local</subfield> |
| 215 |
</datafield> |
| 216 |
</xsl:for-each> |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
<xsl:for-each select="dc:contributer"> |
| 221 |
<xsl:call-template name="persname_template"> |
| 222 |
<xsl:with-param name="string" select="." /> |
| 223 |
<xsl:with-param name="field" select="'100'" /> |
| 224 |
<xsl:with-param name="ind1" select = "'1'" /> |
| 225 |
<xsl:with-param name="ind2" select = "'0'" /> |
| 226 |
<xsl:with-param name="type" select="'contributor'" /> |
| 227 |
</xsl:call-template> |
| 228 |
</xsl:for-each> |
| 229 |
|
| 230 |
<xsl:for-each select="dc:source"> |
| 231 |
<datafield tag="786" ind1="0" ind2=" "> |
| 232 |
<subfield code="n"> |
| 233 |
<xsl:value-of select="."/> |
| 234 |
</subfield> |
| 235 |
</datafield> |
| 236 |
</xsl:for-each> |
| 237 |
|
| 238 |
<xsl:for-each select="dc:relation"> |
| 239 |
<datafield tag="787" ind1="0" ind2=" "> |
| 240 |
<subfield code="n"> |
| 241 |
<xsl:value-of select="."/> |
| 242 |
</subfield> |
| 243 |
</datafield> |
| 244 |
</xsl:for-each> |
| 245 |
|
| 246 |
<xsl:if test="dc:identifier"> |
| 247 |
<datafield tag="856" ind1="4" ind2="1"> |
| 248 |
<subfield code="u"><xsl:value-of select="dc:identifier[last()]" /></subfield> |
| 249 |
<subfield code="z">Connect to this object online.</subfield> |
| 250 |
</datafield> |
| 251 |
</xsl:if> |
| 252 |
</record> |
| 253 |
|
| 254 |
</xsl:template> |
| 255 |
<xsl:template name="persname_template"> |
| 256 |
<xsl:param name="string" /> |
| 257 |
<xsl:param name="field" /> |
| 258 |
<xsl:param name="ind1" /> |
| 259 |
<xsl:param name="ind2" /> |
| 260 |
<xsl:param name="type" /> |
| 261 |
<datafield> |
| 262 |
<xsl:attribute name="tag"> |
| 263 |
<xsl:value-of select="$field" /> |
| 264 |
</xsl:attribute> |
| 265 |
<xsl:attribute name="ind1"> |
| 266 |
<xsl:value-of select="$ind1" /> |
| 267 |
</xsl:attribute> |
| 268 |
<xsl:attribute name="ind2"> |
| 269 |
<xsl:value-of select="$ind2" /> |
| 270 |
</xsl:attribute> |
| 271 |
|
| 272 |
<!-- Sample input: Brightman, Samuel C. (Samuel Charles), 1911-1992 --> |
| 273 |
<!-- Sample output: $aBrightman, Samuel C. $q(Samuel Charles), $d1911-. --> |
| 274 |
<!-- will handle names with dashes e.g. Bourke-White, Margaret --> |
| 275 |
|
| 276 |
<!-- CAPTURE PRIMARY NAME BY LOOKING FOR A PAREN OR A DASH OR NEITHER --> |
| 277 |
<xsl:choose> |
| 278 |
<!-- IF A PAREN, STOP AT AN OPENING PAREN --> |
| 279 |
<xsl:when test="contains($string, '(')!=0"> |
| 280 |
<subfield code="a"> |
| 281 |
<xsl:value-of select="substring-before($string, '(')" /> |
| 282 |
</subfield> |
| 283 |
</xsl:when> |
| 284 |
<!-- IF A DASH, CHECK IF IT'S A DATE OR PART OF THE NAME --> |
| 285 |
<xsl:when test="contains($string, '-')!=0"> |
| 286 |
<xsl:variable name="name_1" select="substring-before($string, '-')" /> |
| 287 |
<xsl:choose> |
| 288 |
<!-- IF IT'S A DATE REMOVE IT --> |
| 289 |
<xsl:when test="translate(substring($name_1, (string-length($name_1)), 1), '0123456789', '9999999999') = '9'"> |
| 290 |
<xsl:variable name="name" select="substring($name_1, 1, (string-length($name_1)-6))" /> |
| 291 |
<subfield code="a"> |
| 292 |
<xsl:value-of select="$name" /> |
| 293 |
</subfield> |
| 294 |
</xsl:when> |
| 295 |
<!-- IF IT'S NOT A DATE, CHECK WHETHER THERE IS A DATE LATER --> |
| 296 |
<xsl:otherwise> |
| 297 |
<xsl:variable name="remainder" select="substring-after($string, '-')" /> |
| 298 |
<xsl:choose> |
| 299 |
<!-- IF THERE'S A DASH, ASSUME IT'S A DATE AND REMOVE IT --> |
| 300 |
<xsl:when test="contains($remainder, '-')!=0"> |
| 301 |
<xsl:variable name="tmp" select="substring-before($remainder, '-')" /> |
| 302 |
<xsl:variable name="name_2" select="substring($tmp, 1, (string-length($tmp)-6))" /> |
| 303 |
<subfield code="a"> |
| 304 |
<xsl:value-of select="$name_1" />-<xsl:value-of select="$name_2" /> |
| 305 |
</subfield> |
| 306 |
</xsl:when> |
| 307 |
<!-- IF THERE'S NO DASH IN THE REMAINDER, OUTPUT IT --> |
| 308 |
<xsl:otherwise> |
| 309 |
<subfield code="a"> |
| 310 |
<xsl:value-of select="$string" /> |
| 311 |
</subfield> |
| 312 |
</xsl:otherwise> |
| 313 |
</xsl:choose> |
| 314 |
</xsl:otherwise> |
| 315 |
</xsl:choose> |
| 316 |
</xsl:when> |
| 317 |
<!-- NO DASHES, NO PARENS, JUST OUTPUT THE NAME --> |
| 318 |
<xsl:otherwise> |
| 319 |
<subfield code="a"> |
| 320 |
<xsl:value-of select="$string" /> |
| 321 |
</subfield> |
| 322 |
</xsl:otherwise> |
| 323 |
</xsl:choose> |
| 324 |
|
| 325 |
<!-- CAPTURE SECONDARY NAME IN PARENS FOR SUBFIELD Q --> |
| 326 |
<xsl:if test="contains($string, '(')!=0"> |
| 327 |
<xsl:variable name="subq_tmp" select="substring-after($string, '(')" /> |
| 328 |
<xsl:variable name="subq" select="substring-before($subq_tmp, ')')" /> |
| 329 |
<subfield code="q"> |
| 330 |
(<xsl:value-of select="$subq" />) |
| 331 |
</subfield> |
| 332 |
</xsl:if> |
| 333 |
|
| 334 |
<!-- CAPTURE DATE FOR SUBFIELD D, ASSUME DATE IS LAST ITEM IN FIELD --> |
| 335 |
<!-- Note: does not work if name has a dash in it --> |
| 336 |
<xsl:if test="contains($string, '-')!=0"> |
| 337 |
<xsl:variable name="date_tmp" select="substring-before($string, '-')" /> |
| 338 |
<xsl:variable name="remainder" select="substring-after($string, '-')" /> |
| 339 |
<xsl:choose> |
| 340 |
<!-- CHECK SECOND HALF FOR ANOTHER DASH; IF PRESENT, ASSUME THAT IS DATE --> |
| 341 |
<xsl:when test="contains($remainder, '-')!=0"> |
| 342 |
<xsl:variable name="tmp" select="substring-before($remainder, '-')" /> |
| 343 |
<xsl:variable name="date_1" select="substring($remainder, (string-length($tmp)-3))" /> |
| 344 |
<!-- CHECK WHETHER IT HAS A NUMBER BEFORE IT AND IF SO, OUTPUT IT AS DATE --> |
| 345 |
<xsl:if test="translate(substring($date_1, 1, 1), '0123456789', '9999999999') = '9'"> |
| 346 |
<subfield code="d"> |
| 347 |
<xsl:value-of select="$date_1" />. |
| 348 |
</subfield> |
| 349 |
</xsl:if> |
| 350 |
</xsl:when> |
| 351 |
<!-- OTHERWISE THIS IS THE ONLY DASH SO TAKE IT --> |
| 352 |
<xsl:otherwise> |
| 353 |
<xsl:variable name="date_2" select="substring($string, (string-length($date_tmp)-3))" /> |
| 354 |
<!-- CHECK WHETHER IT HAS A NUMBER BEFORE IT AND IF SO, OUTPUT IT AS DATE --> |
| 355 |
<xsl:if test="translate(substring($date_2, 1, 1), '0123456789', '9999999999') = '9'"> |
| 356 |
<subfield code="d"> |
| 357 |
<xsl:value-of select="$date_2" />. |
| 358 |
</subfield> |
| 359 |
</xsl:if> |
| 360 |
</xsl:otherwise> |
| 361 |
</xsl:choose> |
| 362 |
</xsl:if> |
| 363 |
<subfield code="e"><xsl:value-of select="$type" /></subfield> |
| 364 |
</datafield> |
| 365 |
</xsl:template> |
| 366 |
|
| 367 |
</xsl:stylesheet> |