forked from SAA-SDT/EAD3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ead2002toEADx.xsl
187 lines (167 loc) · 6.92 KB
/
ead2002toEADx.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs xsi xd"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Feb 27, 2012</xd:p>
<xd:p><xd:b>Author:</xd:b> Terry Catapano</xd:p>
<xd:p>Convert EAD2002 instance to EAD X</xd:p>
</xd:desc>
</xd:doc>
<xsl:output encoding="UTF-8" indent="yes" method="xml"/>
<xsl:variable name="instance-ns-stripped">
<xsl:apply-templates select="/" mode="strip-ns"/>
</xsl:variable>
<xsl:template match="/" name="start">
<xsl:message select="$instance-ns-stripped"/>
<xsl:for-each select="$instance-ns-stripped">
<xsl:apply-templates/>
</xsl:for-each>
</xsl:template>
<!-- ############################################### -->
<!-- IDENTITY TEMPLATE -->
<!-- ############################################### -->
<!-- Whenever you match any node or any attribute -->
<xsl:template match="node()|@*">
<!-- Copy the current node -->
<xsl:copy>
<!-- Including any attributes it has and any child nodes -->
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- ############################################### -->
<!-- DEPRECATED ELEMENTS -->
<!-- ############################################### -->
<xsl:template match="did | dsc | abbr | expan | descgrp | frontmatter">
<xsl:comment>
<xsl:call-template name="removedElement"/>
</xsl:comment>
<xsl:message>
<xsl:call-template name="removedElement"/>
</xsl:message>
<xsl:apply-templates/>
</xsl:template>
<!-- orphan elements -->
<xsl:template match="descgrp/head | dsc/head | archdesc/runner ">
<xsl:comment>
<xsl:call-template name="removedElement"/>
</xsl:comment>
<xsl:message>
<xsl:call-template name="removedElement"/>
</xsl:message>
</xsl:template>
<!-- ############################################### -->
<!-- REVISED CONTENT MODELS -->
<!-- ############################################### -->
<!-- m.refs from container -->
<xsl:template
match="container/ref | container/extref | container/linkgrp | container/bibref | container/title | container/archref">
<xsl:comment>
<xsl:call-template name="removedElement"/>
</xsl:comment>
<xsl:message>
<xsl:call-template name="removedElement"/>
</xsl:message>
</xsl:template>
<xsl:template match="eadheader">
<xsl:comment>
<xsl:text>eadheader now control: </xsl:text>
<xsl:text>Inserting minimal control element</xsl:text>
</xsl:comment>
<xsl:message>
<xsl:text>eadheader now control: </xsl:text>
<xsl:text>Inserting minimal control element</xsl:text>
</xsl:message>
<control>
<eadid>xxx</eadid>
<titleproper>xxx</titleproper>
<maintenanceAgency>
<agencyName>xxxx</agencyName>
</maintenanceAgency>
<maintenanceStatus>derived</maintenanceStatus>
<descriptionMaintenanceHistory>
<maintenanceEvent>
<eventType>xxx</eventType>
<eventDateTime>xxx</eventDateTime>
<agentType>xxx</agentType>
<agent>xxx</agent>
</maintenanceEvent>
</descriptionMaintenanceHistory>
<instanceMaintenanceHistory>
<maintenanceEvent>
<eventType>derived</eventType>
<eventDateTime><xsl:value-of select="current-dateTime()"/></eventDateTime>
<agentType>human</agentType>
<agent>Terry Catapano</agent>
</maintenanceEvent>
</instanceMaintenanceHistory>
<languageDeclaration>
<language languageCode="eng">xxx</language>
<script scriptCode="Latn">xxx</script>
</languageDeclaration>
<publicationStatus>xxx</publicationStatus>
</control>
</xsl:template>
<xsl:template match="archdesc">
<xsl:element name="archdesc">
<xsl:copy-of select="@*"/>
<xsl:comment>
<xsl:text>c ELEMENT created as child of archdesc</xsl:text>
</xsl:comment>
<xsl:message>
<xsl:text>c ELEMENT created as child of archdesc</xsl:text>
</xsl:message>
<c level="{@level}">
<xsl:apply-templates/>
</c>
</xsl:element>
</xsl:template>
<!-- ############################################### -->
<!-- RENAMED ELEMENTS -->
<!-- ############################################### -->
<!-- numbered c's -->
<xsl:template match="c01 | c02 | c03 | c04 | c05 | c06 | c07 | c08 | c09 | c10 | c11 | c12 ">
<xsl:comment>
<xsl:text>ELEMENT </xsl:text>
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
<xsl:text>RENAMED as 'c'</xsl:text>
</xsl:comment>
<xsl:message>
<xsl:text>ELEMENT </xsl:text>
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
<xsl:text>RENAMED as 'c'</xsl:text>
</xsl:message>
<xsl:element name="c">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!-- ############################################### -->
<!-- NAMESPACE STRIPPING ELEMENTS -->
<!-- ############################################### -->
<xsl:template match="*" mode="strip-ns">
<xsl:element name="{local-name()}" inherit-namespaces="no">
<xsl:apply-templates select="@* | node()" mode="strip-ns"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*|text()|comment()|processing-instruction()" mode="strip-ns">
<xsl:copy inherit-namespaces="no" copy-namespaces="no">
<xsl:apply-templates select="@*|node()" mode="strip-ns"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@xsi:schemaLocation" mode="strip-ns"
xpath-default-namespace="http://www.w3.org/2001/XMLSchema-instance"/>
<!-- ############################################### -->
<!-- OTHER TEMPLATES -->
<!-- ############################################### -->
<xsl:template name="removedElement">
<xsl:text>ELEMENT </xsl:text>
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
<xsl:text>REMOVED</xsl:text>
</xsl:template>
</xsl:stylesheet>