forked from cnelsonFLVC/FLVC_Islandora_XSLTs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FLVC_MODS_postprocessing.xsl
104 lines (92 loc) · 4.82 KB
/
FLVC_MODS_postprocessing.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.loc.gov/mods/v3"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:flvc="info:flvc/manifest/v1"
xmlns:marc="http://www.loc.gov/MARC21/slim"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
exclude-result-prefixes="mods dc marc">
<!-- FLVC cleanup_mods.xsl
removes empty attributes, empty elements, and elements containing only attributes
from MODS XML generated by Form Builder
3.0 (July 26, 2013) - edited PURL addition to check for <extension>
2.0 (July 3rd, 2013) - edited to add PURL to MODS after "save"
1.0 (June 7, 2013) - Caitlin Nelson -->
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" media-type="text/xml"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()[normalize-space()]|@*[normalize-space()]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="mods:mods">
<mods:mods xmlns:mods="http://www.loc.gov/mods/v3" xmlns="http://www.loc.gov/mods/v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd"
xmlns:flvc="info:flvc/manifest/v1">
<xsl:apply-templates select="node()[normalize-space()]|@*[normalize-space()]"/>
<xsl:call-template name="newPurl"/>
<xsl:call-template name="typeOfResource_DTconversion"/>
</mods:mods>
</xsl:template>
<xsl:template
match="*[not(node())] | *[not(node()[2]) and node()/self::text() and not(normalize-space())]"/>
<xsl:template name="newPurl">
<xsl:choose>
<xsl:when test="//mods:location[@displayLabel='purl']"/>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="mods:extension/flvc:flvc/flvc:owningInstitution">
<location displayLabel="purl">
<url>
<xsl:text>http://purl.flvc.org/</xsl:text>
<xsl:value-of
select="normalize-space(translate(mods:extension/flvc:flvc/flvc:owningInstitution, $uppercase, $smallcase))"/>
<xsl:text>/fd/</xsl:text>
<xsl:value-of select="normalize-space(mods:identifier[@type='IID'])"/>
</url>
</location>
</xsl:when>
<xsl:otherwise>
<location displayLabel="purl">
<url>
<xsl:text>http://purl.flvc.org/</xsl:text>
<xsl:value-of select="normalize-space(translate((document('info.xml')/root/owner_inst), $uppercase, $smallcase))"/>
<xsl:text>/fd/</xsl:text>
<xsl:value-of select="normalize-space(mods:identifier[@type='IID'])"/>
</url>
</location>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="mods:location">
<xsl:copy>
<xsl:apply-templates select="@*[normalize-space()]"/>
<xsl:apply-templates select="mods:physicalLocation"/>
<xsl:apply-templates select="mods:shelfLocator"/>
<xsl:apply-templates select="mods:url"/>
<xsl:apply-templates select="mods:holdingSimple[normalize-space()]"/>
<xsl:apply-templates select="mods:holdingExternal"/>
<xsl:apply-templates select="node()[not(self::mods:physicalLocation|self::mods:shelfLocator|self::mods:url|self::mods:holdingSimple|self::mods:holdingExternal)]"/>
</xsl:copy>
</xsl:template>
<xsl:template name="typeOfResource_DTconversion">
<xsl:choose>
<xsl:when test="//mods:typeOfResource" />
<xsl:otherwise>
<xsl:if test="document('info.xml')/root/typeOfResource">
<typeOfResource>
<xsl:value-of select="document('info.xml')/root/typeOfResource"/>
</typeOfResource>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>