This repository was archived by the owner on Apr 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_notes.xsl
165 lines (161 loc) · 6.22 KB
/
add_notes.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="text"/>
<xsl:template name="escape">
<xsl:param name="field"/>
<xsl:variable name="quot">"</xsl:variable>
<xsl:variable name="qrep">\\"</xsl:variable>
<xsl:variable name="nl">\n</xsl:variable>
<xsl:variable name="nlrep">\\n</xsl:variable>
<xsl:variable name="result">
<xsl:value-of select="replace(replace(replace($field,$quot,$qrep),$nl,$nlrep),'__','')"/>
</xsl:variable>
<xsl:value-of select="concat($quot,$result,$quot)"/>
</xsl:template>
<xsl:template match="/NewDataSet">
<xsl:variable name="quot">"</xsl:variable>
<xsl:variable name="qrep">\\"</xsl:variable>
<xsl:text>{"records":[</xsl:text>
<xsl:for-each select="RediscoveryExport">
<xsl:variable name="id">
<xsl:value-of select="Collection_Nbr"/>
<xsl:if test="Series_Nbr">
<xsl:value-of select="concat('.',Series_Nbr)"/>
</xsl:if>
<xsl:value-of select="concat('.',File_Unit_Nbr,'.',Item_Nbr)"/>
</xsl:variable>
<xsl:variable name="uri">
<xsl:for-each select="document('archives/tables/objects.xml')/records/record[id = $id]">
<xsl:value-of select="uri"/>
</xsl:for-each>
</xsl:variable>
<xsl:text>{"uri":</xsl:text>
<xsl:choose>
<xsl:when test="$uri != ''">
<xsl:value-of select="concat($quot,$uri,$quot)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($quot,$id,$quot)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>,"notes":[</xsl:text>
<xsl:if test="Drawing_Nbr">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"odd","label":"Drawing Number","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Drawing_Nbr"/>
</xsl:call-template>
<xsl:text>}]</xsl:text>
<xsl:choose>
<xsl:when test="Inscr_Marks or Item_Status or Map_Source or Phys_Char or Provenance or Rights_Usage or Summary_Note">
<xsl:text>},</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="Inscr_Marks">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"odd","label":"Inscription and Marks","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Inscr_Marks"/>
</xsl:call-template>
<xsl:text>}]</xsl:text>
<xsl:choose>
<xsl:when test="Item_Status or Map_Source or Phys_Char or Provenance or Rights_Usage or Summary_Note">
<xsl:text>},</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="Item_Status">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"odd","label":"Item Status","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Item_Status"/>
</xsl:call-template>
<xsl:text>}]</xsl:text>
<xsl:choose>
<xsl:when test="Map_Source or Phys_Char or Provenance or Rights_Usage or Summary_Note">
<xsl:text>},</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="Map_Source">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"odd","label":"Map Source","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Map_Source"/>
</xsl:call-template>
<xsl:text>}]</xsl:text>
<xsl:choose>
<xsl:when test="Phys_Char or Provenance or Rights_Usage or Summary_Note">
<xsl:text>},</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="Phys_Char">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"phystech","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Phys_Char"/>
</xsl:call-template>
<xsl:text>}]</xsl:text>
<xsl:choose>
<xsl:when test="Provenance or Rights_Usage or Summary_Note">
<xsl:text>},</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="Provenance">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"custodhist","label":"Provenance","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Provenance"/>
</xsl:call-template>
<xsl:text>}]</xsl:text>
<xsl:choose>
<xsl:when test="Rights_Usage or Summary_Note">
<xsl:text>},</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="Rights_Usage">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"userestrict","label":"Rights and Usage Statement","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Rights_Usage"/>
</xsl:call-template>
<xsl:text>}]</xsl:text>
<xsl:choose>
<xsl:when test="Summary_Note">
<xsl:text>},</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="Summary_Note">
<xsl:text>{"jsonmodel_type":"note_multipart","type":"odd","label":"Summary Note","publish":true,"subnotes":[{"jsonmodel_type":"note_text","publish":true,"content":</xsl:text>
<xsl:call-template name="escape">
<xsl:with-param name="field" select="Summary_Note"/>
</xsl:call-template>
<xsl:text>}]}</xsl:text>
</xsl:if>
<xsl:text>]}</xsl:text>
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>]}</xsl:text>
</xsl:template>
</xsl:stylesheet>