Start work on MARC21 to Endnote import
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 1 Oct 2009 12:45:49 +0000 (14:45 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 1 Oct 2009 12:45:49 +0000 (14:45 +0200)
etc/Makefile.am
etc/marc21_to_endnote.xsl [new file with mode: 0644]

index d9460c6..ca97e3d 100644 (file)
@@ -11,6 +11,7 @@ etcdata_DATA =  \
  MARC21slim2MODS.xsl \
  MARC21slim2RDFDC.xsl \
  MARC21slimUtils.xsl \
+ marc21_to_endnote.xsl \
  opacxml.xsd
 
 EXTRA_DIST = $(etcdata_DATA) debian.init.d
diff --git a/etc/marc21_to_endnote.xsl b/etc/marc21_to_endnote.xsl
new file mode 100644 (file)
index 0000000..686fddc
--- /dev/null
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+  xmlns:marc="http://www.loc.gov/MARC21/slim"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  >
+  <xsl:output method="text"/>
+  <xsl:strip-space elements="*"/>
+  
+  <xsl:template name="printfield">
+     <xsl:param name="name"/>
+     <xsl:param name="value"/>
+     <xsl:if test="string-length($value) &gt; 0">
+       <xsl:text>%</xsl:text><xsl:value-of select="$name"/>
+       <xsl:text> </xsl:text><xsl:value-of select="$value"/>
+<xsl:text>
+</xsl:text>
+     </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="marc:record">
+    <xsl:variable name="title_medium" select="marc:datafield[@tag='245']/marc:subfield[@code='h']"/>
+    <xsl:variable name="journal_title" select="marc:datafield[@tag='773']/marc:subfield[@code='t']"/>
+    <xsl:variable name="electronic_location_url" select="marc:datafield[@tag='85
+6']/marc:subfield[@code='u']"/>
+    <xsl:variable name="fulltext_a" select="marc:datafield[@tag='900']/marc:subfield[@code='a']"/>
+    <xsl:variable name="fulltext_b" select="marc:datafield[@tag='900']/marc:subfield[@code='b']"/>
+    <xsl:variable name="medium">
+      <xsl:choose>
+       <xsl:when test="$title_medium">
+         <xsl:value-of select="translate($title_medium, ':[]/', '')"/>
+       </xsl:when>
+       <xsl:when test="$fulltext_a">
+         <xsl:text>Electronic Resource</xsl:text>
+       </xsl:when>
+       <xsl:when test="$fulltext_b">
+         <xsl:text>Electronic Resource</xsl:text>
+       </xsl:when>
+       <xsl:when test="$journal_title">
+         <xsl:text>article</xsl:text>
+       </xsl:when>
+       <xsl:otherwise>
+         <xsl:text>Book</xsl:text>
+       </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <!-- Medium -->
+    <xsl:call-template name="printfield">
+      <xsl:with-param name="name">0</xsl:with-param>
+      <xsl:with-param name="value"><xsl:value-of select="$medium"/>
+      </xsl:with-param>
+    </xsl:call-template>
+
+    <!-- Author -->
+    <xsl:choose>
+      <xsl:when test="marc:datafield[@tag='700']">
+       <xsl:for-each select="marc:datafield[@tag='700']">
+         <xsl:call-template name="printfield">
+           <xsl:with-param name="name">A</xsl:with-param>
+           <xsl:with-param name="value"><xsl:value-of select="marc:subfield[@code='a']"/>
+           </xsl:with-param>
+         </xsl:call-template>
+       </xsl:for-each>
+      </xsl:when>
+      <xsl:otherwise>
+      </xsl:otherwise>
+    </xsl:choose>
+      
+    <!-- Title -->
+    <xsl:for-each select="marc:datafield[@tag='245']">
+      <xsl:call-template name="printfield">
+       <xsl:with-param name="name">T</xsl:with-param>
+       <xsl:with-param name="value"><xsl:value-of select="marc:subfield[@code='a']"/>
+       </xsl:with-param>
+      </xsl:call-template>
+    </xsl:for-each>
+    
+    <xsl:for-each select="marc:datafield[@tag='260']">
+      <!-- Place Published -->
+      <xsl:call-template name="printfield">
+       <xsl:with-param name="name">C</xsl:with-param>
+       <xsl:with-param name="value"><xsl:value-of select="marc:subfield[@code='a']"/>
+       </xsl:with-param>
+      </xsl:call-template>
+      <!-- Publisher -->
+      <xsl:call-template name="printfield">
+       <xsl:with-param name="name">I</xsl:with-param>
+       <xsl:with-param name="value"><xsl:value-of select="marc:subfield[@code='b']"/>
+       </xsl:with-param>
+      </xsl:call-template>
+      <!-- Year -->
+      <xsl:call-template name="printfield">
+       <xsl:with-param name="name">D</xsl:with-param>
+       <xsl:with-param name="value"><xsl:value-of select="marc:subfield[@code='c']"/>
+       </xsl:with-param>
+      </xsl:call-template>
+    </xsl:for-each>
+  
+    <!-- Keywords -->
+    <xsl:for-each select="marc:datafield[@tag='650']">
+      <xsl:if test="marc:subfield[@code='a']">
+      <xsl:text>%K </xsl:text>
+      <xsl:value-of select="marc:subfield[@code='a']"/>
+      <xsl:text>
+</xsl:text>
+      </xsl:if>
+  </xsl:for-each>
+  
+    <!-- URL -->
+    <xsl:for-each select="marc:datafield[@tag='856']">
+      <xsl:if test="marc:subfield[@code='u']">
+       <xsl:text>%U </xsl:text>
+       <xsl:value-of select="marc:subfield[@code='u']"/>
+       <xsl:text>
+</xsl:text>
+      </xsl:if>
+  </xsl:for-each>
+  
+    <!-- ISBN -->
+    <xsl:for-each select="marc:datafield[@tag='020']">
+      <xsl:if test="marc:subfield[@code='a']">
+       <xsl:text>%@ </xsl:text>
+       <xsl:value-of select="marc:subfield[@code='a']"/>
+      <xsl:text>
+</xsl:text>
+    </xsl:if>
+  </xsl:for-each>
+  
+    <!-- ISSN -->
+    <xsl:for-each select="marc:datafield[@tag='022']">
+      <xsl:if test="marc:subfield[@code='a']">
+       <xsl:text>%@ </xsl:text>
+       <xsl:value-of select="marc:subfield[@code='a']"/>
+       <xsl:text>
+</xsl:text>
+     </xsl:if>
+  </xsl:for-each>
+
+
+  
+  
+  
+  </xsl:template>
+</xsl:stylesheet>