-
Notifications
You must be signed in to change notification settings - Fork 0
/
interopXmlOut.xsl
119 lines (106 loc) · 4.56 KB
/
interopXmlOut.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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet []>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c3="http://www.cheshire3.org"
exclude-result-prefixes="#all"
version="1.0">
<!--
This file was produced for the Cheshire3 for Archives and the Archives Hub.
Copyright © 2005-2013 the University of Liverpool
-->
<!--
namespaces to be added when needed:
xmlns="urn:isbn:1-931666-22-9"
xsi:schemaLocation="urn:isbn:1-931666-22-9 http://www.loc.gov/ead/ead.xsd"
-->
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:param name="script" select="'/data/'" />
<!-- Strip all audience=internal -->
<!-- this isn't reliable - it returns flat text <xsl:template match='*[@audience="internal"]'
priority="100" /> -->
<xsl:template match="c3:component|c3component">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="*">
<xsl:variable name="tagname" select="local-name(.)" />
<xsl:choose>
<xsl:when
test="$tagname='ead' or $tagname='eadheader' or $tagname='eadid'">
<xsl:element name="{$tagname}">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:when>
<xsl:when test="./@audience='internal'" />
<!-- namespacify cheshire3 component wrapper -->
<xsl:when
test="name(.)='c3:component' or local-name(.)='c3component'">
<c3:component>
<xsl:if test="./@parent">
<xsl:attribute name="c3:parent">
<xsl:value-of select="./@parent" />
</xsl:attribute>
</xsl:if>
<xsl:if test="./@xpath">
<xsl:attribute name="c3:xpath">
<xsl:value-of select="./@xpath" />
</xsl:attribute>
</xsl:if>
<xsl:if test="./@event">
<xsl:attribute name="c3:event">
<xsl:value-of select="./@event" />
</xsl:attribute>
</xsl:if>
<xsl:apply-templates />
</c3:component>
</xsl:when>
<xsl:when test="$tagname = 'persname' or
$tagname = 'famname' or
$tagname = 'corpname' or
$tagname = 'geogname' or
$tagname = 'subject' or
$tagname = 'title'">
<xsl:element name="{$tagname}">
<xsl:copy-of select="@*" />
<xsl:value-of select="normalize-space(.)" />
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$tagname}">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ARCHREF -->
<xsl:template match="archref">
<xsl:copy>
<xsl:copy-of select="@title" />
<xsl:copy-of select="@target" />
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="@role = 'http://www.archiveshub.ac.uk/apps/linkroles/related' or
@role = 'http://www.archiveshub.ac.uk/apps/linkroles/extended' or
@role = 'http://www.archiveshub.ac.uk/apps/linkroles/child' or
@role = 'http://www.archiveshub.ac.uk/apps/linkroles/parent' or
@role = 'http://www.archiveshub.ac.uk/apps/linkroles/descendant' or
@role = 'http://www.archiveshub.ac.uk/apps/linkroles/ancestor'">
<xsl:value-of select="$script" />
<xsl:value-of select="@href" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<!-- inner XML -->
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>