-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathslurp_all_ead_to_solr.xslt
57 lines (49 loc) · 1.94 KB
/
slurp_all_ead_to_solr.xslt
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- EAD -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:foxml="info:fedora/fedora-system:def/foxml#">
<xsl:template match="foxml:datastream[@ID='EAD']/foxml:datastreamVersion[last()]" name="index_EAD">
<xsl:param name="content"/>
<xsl:param name="prefix"></xsl:param>
<xsl:param name="suffix">ms</xsl:param>
<!--
XXX: EAD doesn't seem to be reliably namespaced? Let's just match the root
"ead" element.
-->
<xsl:apply-templates mode="slurping_EAD" select="$content/*[local-name() = 'ead']">
<xsl:with-param name="prefix" select="$prefix"/>
<xsl:with-param name="suffix" select="$suffix"/>
</xsl:apply-templates>
</xsl:template>
<!-- Build up the list prefix with the element context. -->
<xsl:template match="*" mode="slurping_EAD">
<xsl:param name="prefix"/>
<xsl:param name="suffix"/>
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz_'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ '" />
<xsl:variable name="this_prefix">
<xsl:value-of select="concat($prefix, local-name(), '_')"/>
<xsl:if test="@type">
<xsl:value-of select="concat(@type, '_')"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="textValue">
<xsl:value-of select="normalize-space(text())"/>
</xsl:variable>
<xsl:if test="$textValue">
<field>
<xsl:attribute name="name">
<xsl:value-of select="concat($this_prefix, $suffix)"/>
</xsl:attribute>
<xsl:value-of select="$textValue"/>
</field>
</xsl:if>
<xsl:apply-templates mode="slurping_EAD">
<xsl:with-param name="prefix" select="$this_prefix"/>
<xsl:with-param name="suffix" select="$suffix"/>
</xsl:apply-templates>
</xsl:template>
<!-- Avoid using text alone. -->
<xsl:template match="text()" mode="slurping_EAD"/>
</xsl:stylesheet>