blob: 51c410a6d8c32bf01c27c59e81788b04e38af8a3 (
plain)
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tc="http://periapsis.org/tellico/"
xmlns:math="http://exslt.org/math"
xmlns:a="uri:attribute"
exclude-result-prefixes="tc a"
extension-element-prefixes="math"
version="1.0">
<!--
===================================================================
Tellico XSLT file - used for exporting to GCstar
Copyright (C) 2008 Robby Stephenson - robby@periapsis.org
This XSLT stylesheet is designed to be used with the 'Tellico'
application, which can be found at
http://www.periapsis.org/tellico/
===================================================================
-->
<!-- the mapping from gcstar attribute to tellico element is automated here -->
<!-- @name is the gcstar attribute name, the value is the tellico element local-name() -->
<!-- bool attributes are special, and some only apply to certain collection types -->
<a:attributes>
<a:attribute name="isbn">isbn</a:attribute>
<a:attribute name="title">title</a:attribute>
<a:attribute name="publisher">publisher</a:attribute>
<a:attribute name="publication">pub_year</a:attribute>
<a:attribute name="language">language</a:attribute>
<a:attribute name="serie">series</a:attribute>
<a:attribute name="edition">edition</a:attribute>
<a:attribute name="pages">pages</a:attribute>
<a:attribute name="added">pur_date</a:attribute>
<a:attribute name="acquisition">pur_date</a:attribute>
<a:attribute name="location">location</a:attribute>
<a:attribute name="translator">translator</a:attribute>
<a:attribute name="artist">artist</a:attribute>
<a:attribute name="director">director</a:attribute>
<a:attribute name="date">year</a:attribute>
<a:attribute name="video">format</a:attribute>
<a:attribute name="original">origtitle</a:attribute>
<a:attribute name="format">binding</a:attribute>
<a:attribute name="format">medium</a:attribute>
<a:attribute name="format">format</a:attribute>
<a:attribute name="web">url</a:attribute>
<a:attribute name="webPage">url</a:attribute>
<a:attribute name="read" format="bool" type="GCbooks">read</a:attribute>
<a:attribute name="seen" format="bool" type="GCfilms">seen</a:attribute>
<a:attribute name="favourite" format="bool">favorite</a:attribute>
<a:attribute name="label">label</a:attribute>
<a:attribute name="release">year</a:attribute>
<a:attribute name="composer">composer</a:attribute>
<a:attribute name="producer">producer</a:attribute>
</a:attributes>
<xsl:variable name="collType">
<xsl:choose>
<xsl:when test="tc:tellico/tc:collection/@type=2 or tc:tellico/tc:collection/@type=5">
<xsl:text>GCbooks</xsl:text>
</xsl:when>
<xsl:when test="tc:tellico/tc:collection/@type=3">
<xsl:text>GCfilms</xsl:text>
</xsl:when>
<xsl:when test="tc:tellico/tc:collection/@type=4">
<xsl:text>GCmusics</xsl:text>
</xsl:when>
<xsl:when test="tc:tellico/tc:collection/@type=8">
<xsl:text>GCcoins</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- grab all the applicable attributes once -->
<xsl:variable name="attributes" select="document('')/*/a:attributes/a:attribute[not(@type) or @type=$collType]"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="tc:tellico"/>
</xsl:template>
<xsl:template match="tc:tellico">
<xsl:apply-templates select="tc:collection"/>
</xsl:template>
<xsl:template match="tc:collection[@type<2 or @type>5 and not(@type=8)]">
<xsl:message terminate="yes">
<xsl:text>GCstar export is not supported for this collection type.</xsl:text>
</xsl:message>
</xsl:template>
<xsl:template match="tc:collection[@type>1 and @type<6]">
<collection items="{count(tc:entry)}" type="{$collType}">
<information>
<maxId>
<xsl:value-of select="math:max(tc:entry/@id)"/>
</maxId>
</information>
<xsl:apply-templates select="tc:entry"/>
</collection>
</xsl:template>
<!-- no output for fields or images -->
<xsl:template match="tc:fields"/>
<xsl:template match="tc:images"/>
<xsl:template match="tc:entry">
<xsl:variable name="entry" select="."/>
<item id="{@id}" rating="{tc:rating * 2}">
<xsl:for-each select="$attributes">
<xsl:call-template name="handle-attribute">
<xsl:with-param name="att" select="."/>
<xsl:with-param name="entry" select="$entry"/>
</xsl:call-template>
</xsl:for-each>
<xsl:if test="tc:running-time">
<xsl:attribute name="time">
<xsl:value-of select="concat(tc:running-time, ' min')"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="tc:nationalitys">
<xsl:attribute name="country">
<xsl:for-each select="tc:nationalitys/tc:nationality">
<xsl:value-of select="."/>
<xsl:if test="position() < last()">
<xsl:text> / </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="tc:certification">
<xsl:attribute name="age">
<xsl:choose>
<xsl:when test="tc:certification = 'U (USA)'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="tc:certification = 'G (USA)'">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:when test="tc:certification = 'PG (USA)'">
<xsl:text>5</xsl:text>
</xsl:when>
<xsl:when test="tc:certification = 'PG-13 (USA)'">
<xsl:text>13</xsl:text>
</xsl:when>
<xsl:when test="tc:certification = 'R (USA)'">
<xsl:text>18</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<!-- for coin grade, GCstar uses numbers only -->
<xsl:if test="tc:grade">
<xsl:attribute name="condition">
<!-- remove everything but numbers -->
<xsl:value-of select="translate(tc:grade,translate(tc:grade,'0123456789', ''),'')"/>
</xsl:attribute>
</xsl:if>
<!-- for books -->
<comments>
<xsl:value-of select="tc:comments"/>
</comments>
<authors>
<xsl:call-template name="multiline">
<xsl:with-param name="elem" select="tc:authors"/>
</xsl:call-template>
</authors>
<genre>
<xsl:call-template name="multiline">
<xsl:with-param name="elem" select="tc:genres"/>
</xsl:call-template>
</genre>
<tags>
<xsl:call-template name="multiline">
<xsl:with-param name="elem" select="tc:keywords"/>
</xsl:call-template>
</tags>
<!-- for movies -->
<comment> <!-- note the lack of an 's' -->
<xsl:value-of select="tc:comments"/>
</comment>
<synopsis>
<xsl:value-of select="tc:plot"/>
</synopsis>
<!--
<directors>
<xsl:call-template name="multiline">
<xsl:with-param name="elem" select="tc:directors"/>
</xsl:call-template>
</directors>
-->
<actors>
<xsl:call-template name="table">
<xsl:with-param name="elem" select="tc:casts"/>
</xsl:call-template>
</actors>
<subt>
<xsl:call-template name="multiline">
<xsl:with-param name="elem" select="tc:subtitles"/>
</xsl:call-template>
</subt>
<xsl:apply-templates select="tc:languages"/>
<!-- for music -->
<xsl:apply-templates select="tc:tracks"/>
</item>
</xsl:template>
<xsl:template match="tc:languages">
<audio>
<xsl:for-each select="tc:language">
<line>
<col>
<xsl:value-of select="."/>
</col>
<col>
<!-- expect a language to always have a track -->
<xsl:value-of select="../../tc:audio-tracks/tc:audio-track[position()]"/>
</col>
</line>
</xsl:for-each>
</audio>
</xsl:template>
<xsl:template match="tc:tracks">
<tracks>
<xsl:for-each select="tc:track">
<line>
<col>
<xsl:value-of select="position()"/>
</col>
<col>
<xsl:value-of select="tc:column[1]"/>
</col>
<col>
<xsl:value-of select="tc:column[3]"/>
</col>
</line>
</xsl:for-each>
</tracks>
</xsl:template>
<xsl:template name="multiline">
<xsl:param name="elem"/>
<xsl:for-each select="$elem/child::*">
<line>
<col>
<xsl:value-of select="."/>
</col>
</line>
</xsl:for-each>
</xsl:template>
<xsl:template name="table">
<xsl:param name="elem"/>
<xsl:for-each select="$elem/child::*">
<line>
<xsl:for-each select="child::*">
<col>
<xsl:value-of select="."/>
</col>
</xsl:for-each>
</line>
</xsl:for-each>
</xsl:template>
<xsl:template name="handle-attribute">
<xsl:param name="att"/>
<xsl:param name="entry"/>
<!-- should technically check namespace, too, but unlikely to match -->
<xsl:variable name="value" select="$entry//*[local-name()=$att][1]"/>
<xsl:choose>
<xsl:when test="$att/@format='bool'">
<xsl:attribute name="{$att/@name}">
<xsl:value-of select="number($value='true')"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:if test="string-length($value) > 0">
<xsl:attribute name="{$att/@name}">
<xsl:value-of select="$value"/>
</xsl:attribute>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<!-- Local Variables: -->
<!-- sgml-indent-step: 1 -->
<!-- sgml-indent-data: 1 -->
<!-- End: -->
|