-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaeon-links.xsl
199 lines (163 loc) · 10.8 KB
/
aeon-links.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
xmlns:mdc="http://mdc"
xmlns:ead3="http://ead3.archivists.org/schema/" exclude-result-prefixes="xs ead3 fox mdc"
version="3.0">
<xsl:param name="include-Aeon-link" select="false()" as="xs:boolean"/>
<!-- 'container' or 'component' are recognized values. -->
<xsl:param name="request-link-for-distinct-type" select="'container'" as="xs:string"/>
<xsl:param name="production-or-test-Aeon" select="'test'"/>
<xsl:param name="request-link-text" select="'REQUEST'" as="xs:string"/>
<!-- using this twice now, so i should likely move this and re-use on the cover-page.xsl file... but for now, since it might not be useful in the PDF requests after all... -->
<xsl:variable name="export-timestamp" select="'&PDF-timestamp=' || /ead3:ead/ead3:control[1]/ead3:maintenancehistory[1]/ead3:maintenanceevent[1]/ead3:eventdatetime[1]"/>
<xsl:variable name="aeon-site">
<xsl:variable name="repo-to-site-code">
<!-- 3-character codes, per request -->
<xsl:choose>
<xsl:when test="$repository-code = ('arts', 'vrc')">
<xsl:text>ART</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = 'beinecke'">
<xsl:text>BRBL</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = 'divinity'">
<xsl:text>DIV</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = 'lwl'">
<xsl:text>LWL</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = 'med'">
<xsl:text>MHL</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = 'mssa'">
<xsl:text>MSS</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = ('music', 'oham')">
<xsl:text>MUS</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = 'ycba'">
<xsl:text>BCA</xsl:text>
</xsl:when>
<xsl:when test="$repository-code = 'ypm'">
<xsl:text>YPM</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>MSS</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="'&Site=' || $repo-to-site-code"/>
</xsl:variable>
<xsl:variable name="aspace-base-URL" select="if ($production-or-test-Aeon eq 'test') then 'https://testarchivesspace.library.yale.edu/api/' else 'https://archivesspace.library.yale.edu/api/'"/>
<xsl:variable name="aeon-base-URL">
<xsl:choose>
<xsl:when test="$repository-code eq 'beinecke' and $production-or-test-Aeon eq 'test'">
<xsl:value-of select="'https://aeon-test.library.yale.edu/aeon.dll?Action=10&Form=20'"/>
</xsl:when>
<xsl:when test="$repository-code eq 'beinecke' and $production-or-test-Aeon eq 'prod'">
<xsl:value-of select="'https://aeon.library.yale.edu/aeon.dll?Action=10&Form=20'"/>
</xsl:when>
<xsl:when test="not($repository-code eq 'beinecke') and $production-or-test-Aeon eq 'test'">
<xsl:value-of select="'https://aeon-test.library.yale.edu/aeon.dll?Action=10&Form=20'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'https://aeon.library.yale.edu/aeon.dll?Action=10&Form=20'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="aeon-document-type">
<xsl:choose>
<xsl:when test="$repository-code eq 'beinecke'">
<xsl:value-of select="'&DocumentType=BRBL'"/>
</xsl:when>
<xsl:when test="starts-with(normalize-space(ead3:ead/ead3:control/ead3:recordid[1]), 'mssa.ru')">
<xsl:value-of select="'&DocumentType=Archives'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'&DocumentType=Manuscript'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="aeon-call-number" select="'&CallNumber=' || $collection-identifier"/>
<xsl:variable name="aeon-value">
<xsl:choose>
<xsl:when test="$repository-code eq 'beinecke'">
<xsl:value-of select="'&Value=GenericRequestManuscript'"/>
</xsl:when>
<xsl:when test="$office-of-origin-request">
<xsl:value-of select="'&Value=GenericRequestOrigin'"/>
</xsl:when>
<xsl:when test="starts-with(normalize-space(ead3:ead/ead3:control/ead3:recordid[1]), 'mssa.ru')">
<xsl:value-of select="'&Value=GenericRequestArchive'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'&Value=GenericRequestManuscript'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="aeon-collection-title" select="'&ItemTitle=' || $collection-title"/>
<xsl:variable name="aeon-collection-title-custom-field" select="'&CollectionTitle=' || $collection-title"/>
<xsl:variable name="aeon-ead-id" select="'&RootRecordURI=' || $finding-aid-identifier"/>
<xsl:variable name="aeon-citation" select="'&ItemCitation=' || /ead3:ead/ead3:archdesc/ead3:prefercite/normalize-space(ead3:p[1])"/>
<xsl:variable name="aspace-location-list">
<xsl:if test="$include-Aeon-link eq true()">
<xsl:variable name="location-urls" as="item()*">
<xsl:sequence select="distinct-values(/ead3:ead/ead3:archdesc/ead3:dsc//ead3:container/substring-after(@altrender, ' '))"/>
</xsl:variable>
<locations>
<xsl:for-each select="$location-urls[normalize-space()]">
<location url="{.}">
<xsl:variable name="location-json" as="map(*)">
<xsl:sequence select="unparsed-text($aspace-base-URL || .) => parse-json()"/>
</xsl:variable>
<xsl:value-of select="$location-json?title => replace('\[\d{5}, ', '[')"/>
</location>
</xsl:for-each>
</locations>
</xsl:if>
</xsl:variable>
<xsl:template name="add-aeon-link">
<xsl:variable name="container-id" select="if (contains(@altrender, ' ')) then tokenize(substring-before(., ' '), '/')[last()] else tokenize(@altrender, '/')[last()]"/>
<xsl:variable name="location-url" select="substring-after(@altrender, ' ')"/>
<xsl:variable name="aeon-item-volume" select="'&ItemVolume=' || concat(upper-case(substring(@localtype,1,1)), substring(@localtype,2)) || ' ' || normalize-space(.)"/>
<xsl:variable name="aeon-restricted" select="'&TopContainerRestriction=' || (if (../@ancestor-access-restrictions) then 'Y' else 'N')"/>
<xsl:variable name="aeon-reference-number" select="if (@containerid) then '&ReferenceNumber=' || @containerid else ''"/>
<xsl:variable name="aeon-sub-location" select="if (@encodinganalog) then '&SubLocation=' || @encodinganalog else ''"/>
<xsl:variable name="aeon-location-uri" select="if (normalize-space($location-url)) then '&LocationURI=' || $location-url else ''"/>
<xsl:variable name="aeon-location">
<xsl:if test="normalize-space($location-url)">
<xsl:value-of select="'&Location=' || $aspace-location-list/locations/location[@url = $location-url]"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="aeon-access-restriction-types" select="if (normalize-space(../@ancestor-access-restrictions)) then ('&RestrictionCode=' || string-join(../@ancestor-access-restrictions, ';')) else ''"/>
<xsl:variable name="aeon-series-id" select="if (normalize-space(../@series)) then ('&ItemSeries=' || ../@series) else ''"/>
<xsl:variable name="aeon-folder" select="if ($request-link-for-distinct-type eq 'component'
and following::ead3:container[@parent][1])
then '&ItemFolder='
|| upper-case(substring(following::ead3:container[@parent][1]/@localtype,1,1))
|| substring(following::ead3:container[@parent][1]/@localtype,2)
|| ' '
|| following::ead3:container[@parent][1]
|| ': '
|| substring(../@component-title, 1, 25)
|| (if (string-length(../@component-title) eq 26) then '...' else ())
else ()"/>
<xsl:variable name="aeon-request-uri" select="if ($request-link-for-distinct-type eq 'component')
(: yes, right now, we're always pointing folks to the production staff URL. that's because the 'test' aspect is in regards to test Aeon, not test ASpace. :)
then '&EADNumber=https://archivesspace.library.yale.edu/resources/' || tokenize($resource-url, '/')[last()] || '#tree::archival_object_' || tokenize(../@component-url, '/')[last()]
else '&EADNumber=https://archivesspace.library.yale.edu/top_containers/' || $container-id"
/>
<xsl:variable name="link" select="$aeon-base-URL || $aeon-value || $aeon-site || $aeon-document-type || '&SystemID=PDF' || $aeon-call-number || $aeon-citation || $aeon-ead-id || $aeon-access-restriction-types || $aeon-collection-title || $aeon-collection-title-custom-field || $aeon-item-volume || $aeon-location || $aeon-location-uri || $aeon-reference-number
|| $aeon-request-uri || $aeon-restricted || $aeon-series-id || $aeon-sub-location || $aeon-folder || $export-timestamp"/>
<!-- test and see if i need to use encode-for-uri -->
<fo:block xsl:use-attribute-sets="request.block">
<fo:basic-link external-destination="url({$link})" xsl:use-attribute-sets="ref">
<xsl:value-of select="if ($request-link-for-distinct-type eq 'component' and following::ead3:container[@parent][1])
then string-join(($request-link-text, upper-case(following::ead3:container[@parent][1]/@localtype), following::ead3:container[@parent][1]), ' ')
else string-join(($request-link-text, upper-case(@localtype), .), ' ')"/>
</fo:basic-link>
</fo:block>
</xsl:template>
</xsl:stylesheet>