Menu

[r3279]: / branches / franck / import / xsl / vudl.xsl  Maximize  Restore  History

Download this file

144 lines (129 with data), 6.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mets="http://www.loc.gov/METS/"
xmlns:METS="http://www.loc.gov/METS/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:php="http://php.net/xsl"
xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:param name="institution">My University</xsl:param>
<xsl:param name="collection">Digital Library</xsl:param>
<xsl:param name="track_changes">0</xsl:param>
<xsl:param name="solr_core">biblio</xsl:param>
<xsl:template match="METS:mets">
<add>
<doc>
<!-- ID -->
<field name="id">
<xsl:value-of select="//@OBJID"/>
</field>
<!-- CHANGE TRACKING DATES -->
<xsl:if test="$track_changes != 0">
<field name="first_indexed">
<xsl:value-of select="php:function('vufind::get_first_indexed', $solr_core, string(//@OBJID), string(//METS:metsHdr/@LASTMODDATE))"/>
</field>
<field name="last_indexed">
<xsl:value-of select="php:function('vufind::get_last_indexed', $solr_core, string(//@OBJID), string(//METS:metsHdr/@LASTMODDATE))"/>
</field>
</xsl:if>
<!-- RECORDTYPE -->
<field name="recordtype">vudl</field>
<!-- FULLRECORD -->
<!-- disabled for now; records are so large that they cause memory problems!
<field name="fullrecord">
<xsl:copy-of select="php:function('vufind::xml_as_text', //METS:mets)"/>
</field>
-->
<!-- ALLFIELDS -->
<field name="allfields">
<xsl:value-of select="normalize-space(string(//METS:mets))"/>
</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::map_string', normalize-space(string(.)), 'language_map_iso639-1.properties')"/>
</field>
</xsl:if>
</xsl:for-each>
</xsl:if>
<!-- FORMAT -->
<field name="format">Online</field>
<!-- 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::strip_articles', 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>
</xsl:if>
<!-- URL -->
<xsl:if test="//dc:identifier">
<field name="url">
<xsl:value-of select="//dc:identifier[normalize-space()]"/>
</field>
</xsl:if>
<!-- FULL TEXT -->
<field name="fulltext">
<xsl:for-each select="//METS:fileGrp[@USE=&quot;OCR-DIRTY&quot;]/METS:file/METS:FLocat">
<xsl:value-of select="php:function('vufind::harvest_text_file', string(./@xlink:href))"/>
</xsl:for-each>
<xsl:for-each select="//METS:fileGrp[@USE=&quot;TRANSCRIPTION&quot;]/METS:file/METS:FLocat">
<xsl:value-of select="php:function('vufind::harvest_with_aperture', string(./@xlink:href))"/>
</xsl:for-each>
</field>
</doc>
</add>
</xsl:template>
</xsl:stylesheet>