]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0299.data.marc21expand880.sql
LP#1643709: Stamping upgrade scripts
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0299.data.marc21expand880.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0299'); -- Galen Charlton
4
5 insert INTO CONFIG.xml_transform(name, namespace_uri, prefix, xslt)
6 VALUES ('marc21expand880', 'http://www.loc.gov/MARC21/slim', 'marc', $$<?xml version="1.0" encoding="UTF-8"?>
7 <xsl:stylesheet
8     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
9     xmlns:marc="http://www.loc.gov/MARC21/slim"
10     version="1.0">
11 <!--
12 Copyright (C) 2010  Equinox Software, Inc.
13 Galen Charlton <gmc@esilibrary.cOM.
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License
17 as published by the Free Software Foundation; either version 2
18 of the License, or (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 GNU General Public License for more details.
24
25 marc21_expand_880.xsl - stylesheet used during indexing to
26                         map alternative graphical representations
27                         of MARC fields stored in 880 fields
28                         to the corresponding tag name and value.
29
30 For example, if a MARC record for a Chinese book has
31
32 245.00 $6 880-01 $a Ba shi san nian duan pian xiao shuo xuan
33 880.00 $6 245-01/$1 $a八十三年短篇小說選
34
35 this stylesheet will transform it to the equivalent of
36
37 245.00 $6 880-01 $a Ba shi san nian duan pian xiao shuo xuan
38 245.00 $6 245-01/$1 $a八十三年短篇小說選
39
40 -->
41     <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
42
43     <xsl:template match="@*|node()">
44         <xsl:copy>
45             <xsl:apply-templates select="@*|node()"/>
46         </xsl:copy>
47     </xsl:template>
48
49     <xsl:template match="//marc:datafield[@tag='880']">
50         <xsl:if test="./marc:subfield[@code='6'] and string-length(./marc:subfield[@code='6']) &gt;= 6">
51             <marc:datafield>
52                 <xsl:attribute name="tag">
53                     <xsl:value-of select="substring(./marc:subfield[@code='6'], 1, 3)" />
54                 </xsl:attribute>
55                 <xsl:attribute name="ind1">
56                     <xsl:value-of select="@ind1" />
57                 </xsl:attribute>
58                 <xsl:attribute name="ind2">
59                     <xsl:value-of select="@ind2" />
60                 </xsl:attribute>
61                 <xsl:apply-templates />
62             </marc:datafield>
63         </xsl:if>
64     </xsl:template>
65     
66 </xsl:stylesheet>$$);
67
68 COMMIT;