From c3c871b1d7e7f03ec5758e98d2647cfb52b1d87b Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 9 Oct 2012 13:51:13 -0400
Subject: [PATCH] Adding sample Greenstone Digital Library import
 configurations (from VUFIND-588; thanks to Mohan Raj Pradhan).

---
 import/gsdl.properties |  23 +++++++
 import/xsl/gsdl.xsl    | 151 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 174 insertions(+)
 create mode 100644 import/gsdl.properties
 create mode 100644 import/xsl/gsdl.xsl

diff --git a/import/gsdl.properties b/import/gsdl.properties
new file mode 100644
index 00000000000..f81c22c9ccc
--- /dev/null
+++ b/import/gsdl.properties
@@ -0,0 +1,23 @@
+; XSLT Import Settings for Greenstone Digital Library (GSDL)
+[General]
+; REQUIRED: Name of XSLT file to apply.  Path is relative to the import/xsl directory
+; of the VuFind installation (or your local override directory).
+xslt = gsdl.xsl
+; OPTIONAL: PHP function(s) to register for use within XSLT file.  You may repeat
+; this line to register multiple PHP functions.
+;php_function[] = str_replace
+; OPTIONAL: PHP class filled with public static functions for use by the XSLT file.
+; The class will be autoloaded using a prefix of VF_XSLT_Import_ (i.e. you need to
+; define VF_XSLT_Import_VuFind in your library directory); the short name will be
+; used from within the XSLT code.  You may repeat this line to load multiple custom
+; classes.
+custom_class[] = VuFind
+
+; XSLT parameters -- any key/value pairs set here will be passed as parameters to
+; the XSLT file, allowing local values to be set without modifying XSLT code.
+[Parameters]
+institution = "My Institute"
+collection = "GSDL"
+
+; This URL will be used to resolve urn: identifiers.
+gsdlurl = http://localhost/greenstone/cgi-bin/library.cgi?a=d&c=demo&d=
diff --git a/import/xsl/gsdl.xsl b/import/xsl/gsdl.xsl
new file mode 100644
index 00000000000..25dad4dd062
--- /dev/null
+++ b/import/xsl/gsdl.xsl
@@ -0,0 +1,151 @@
+<!-- available fields are defined in solr/biblio/conf/schema.xml -->
+<!-- This xsl file is similar to xsl file of DSpace as both system use Dublin Core MetadataSet -->
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:php="http://php.net/xsl"
+    xmlns:xlink="http://www.w3.org/2001/XMLSchema-instance">
+    <xsl:output method="xml" indent="yes" encoding="utf-8"/>
+    <xsl:param name="institution">My Institute</xsl:param>
+    <xsl:param name="collection">DEMO</xsl:param>
+    <xsl:param name="gsdlurl">http://greenstone.org</xsl:param>
+    <xsl:template match="oai_dc:dc">
+        <add>
+            <doc>
+                <!-- ID -->
+                <!-- Important: This relies on an <identifier> tag being injected by the OAI-PMH harvester. -->
+                <field name="id">
+                    <xsl:value-of select="//identifier"/>
+                </field>
+                <!-- RECORDTYPE -->
+                <field name="recordtype">gsdl</field>
+                <!-- FULLRECORD -->
+                <!-- disabled for now; records are so large that they cause memory problems!
+                <field name="fullrecord">
+                    <xsl:copy-of select="php:function('VuFind::xmlAsText', //oai_dc:dc)"/>
+                </field>
+                  -->
+                <!-- ALLFIELDS -->
+                <field name="allfields">
+                    <xsl:value-of select="normalize-space(string(//oai_dc:dc))"/>
+                </field>
+                <!-- INSTITUTION -->
+                <field name="institution">
+                    <xsl:value-of select="$institution" />
+                </field>
+
+                <!-- COLLECTION -->
+                <field name="collection">
+                    <xsl:value-of select="$collection" />
+                </field>
+
+                <!-- LANGUAGE -->
+                <xsl:if test="//dc:language">
+                    <xsl:for-each select="//dc:language">
+                        <xsl:if test="string-length() > 0">
+                            <field name="language">
+                                <xsl:value-of select="php:function('VuFind::mapString', normalize-space(string(.)), 'language_map_iso639-1.properties')"/>
+                            </field>
+                        </xsl:if>
+                    </xsl:for-each>
+                </xsl:if>
+
+                <!-- FORMAT -->
+                <field name="format">eResources</field>
+
+                <!-- SUBJECT -->
+                <xsl:if test="//dc:subject">
+                    <xsl:for-each select="//dc:subject">
+                        <xsl:if test="string-length() > 0">
+                            <field name="topic">
+                                <xsl:value-of select="normalize-space()"/>
+                            </field>
+                        </xsl:if>
+                    </xsl:for-each>
+                </xsl:if>
+                <!-- DESCRIPTION -->
+                <xsl:if test="//dc:description">
+                    <field name="description">
+                        <xsl:value-of select="//dc:description" />
+                    </field>
+                </xsl:if>
+                <!-- ADVISOR / CONTRIBUTOR -->
+                <xsl:if test="//dc:contributor[normalize-space()]">
+                    <field name="author_additional">
+                        <xsl:value-of select="//dc:contributor[normalize-space()]" />
+                    </field>
+                </xsl:if>
+
+                <!-- AUTHOR -->
+                <xsl:if test="//dc:creator">
+                    <xsl:for-each select="//dc:creator">
+                        <xsl:if test="normalize-space()">
+                            <!-- author is not a multi-valued field, so we'll put
+                                 first value there and subsequent values in author2.
+                             -->
+                            <xsl:if test="position()=1">
+                                <field name="author">
+                                    <xsl:value-of select="normalize-space()"/>
+                                </field>
+                                <field name="author-letter">
+                                    <xsl:value-of select="normalize-space()"/>
+                                </field>
+                            </xsl:if>
+                            <xsl:if test="position()>1">
+                                <field name="author2">
+                                    <xsl:value-of select="normalize-space()"/>
+                                </field>
+                            </xsl:if>
+                        </xsl:if>
+                    </xsl:for-each>
+                </xsl:if>
+                <!-- TITLE -->
+                <xsl:if test="//dc:title[normalize-space()]">
+                    <field name="title">
+                        <xsl:value-of select="//dc:title[normalize-space()]"/>
+                    </field>
+                    <field name="title_short">
+                        <xsl:value-of select="//dc:title[normalize-space()]"/>
+                    </field>
+                    <field name="title_full">
+                        <xsl:value-of select="//dc:title[normalize-space()]"/>
+                    </field>
+                    <field name="title_sort">
+                        <xsl:value-of select="php:function('VuFind::stripArticles', string(//dc:title[normalize-space()]))"/>
+                    </field>
+                </xsl:if>
+                <!-- PUBLISHER -->
+                <xsl:if test="//dc:publisher[normalize-space()]">
+                    <field name="publisher">
+                        <xsl:value-of select="//dc:publisher[normalize-space()]"/>
+                    </field>
+                </xsl:if>
+                <!-- PUBLISHDATE -->
+                <xsl:if test="//dc:date">
+                    <field name="publishDate">
+                        <xsl:value-of select="substring(//dc:date, 1, 4)"/>
+                    </field>
+                    <field name="publishDateSort">
+                        <xsl:value-of select="substring(//dc:date, 1, 4)"/>
+                    </field>
+                </xsl:if>
+                <!-- URL -->
+                <xsl:for-each select="//dc:identifier">
+                    <xsl:choose>
+                        <xsl:when test="contains(., '://')">
+                               <field name="url">
+                                   <xsl:value-of select="." />
+                               </field>
+                        </xsl:when>
+                        <xsl:when test="contains(., 'urn:')">
+                               <field name="url">
+                                   <xsl:value-of select="$gsdlurl" /><xsl:value-of select="." />
+                               </field>
+                        </xsl:when>
+                    </xsl:choose>
+                </xsl:for-each>
+            </doc>
+        </add>
+    </xsl:template>
+</xsl:stylesheet>
-- 
GitLab