This file is indexed.

/usr/share/tellico/gcstar2tellico.xsl is in tellico-data 3.1.2-0.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tc="http://periapsis.org/tellico/"
                xmlns:exsl="http://exslt.org/common"
                xmlns:str="http://exslt.org/strings"
                extension-element-prefixes="str exsl"
                version="1.0">

<!--
   ===================================================================
   Tellico XSLT file - used for importing GCstar data.

   Copyright (C) 2007-2013 Robby Stephenson <robby@periapsis.org>

   This XSLT stylesheet is designed to be used with the 'Tellico'
   application, which can be found at http://tellico-project.org

   ===================================================================
-->

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
            doctype-public="-//Robby Stephenson/DTD Tellico V11.0//EN"
            doctype-system="http://periapsis.org/tellico/dtd/v11/tellico.dtd"/>

<!-- base url for gcstar file -->
<xsl:param name="baseDir" select="''"/>

<xsl:variable name="coll">
 <xsl:choose>
  <xsl:when test="/collection[1]/@type='GCbooks'">
   <xsl:text>2</xsl:text>
  </xsl:when>
  <xsl:when test="/collection[1]/@type='GCfilms'">
   <xsl:text>3</xsl:text>
  </xsl:when>
  <xsl:when test="/collection[1]/@type='GCmusics'">
   <xsl:text>4</xsl:text>
  </xsl:when>
  <xsl:when test="/collection[1]/@type='GCcomics'">
   <xsl:text>6</xsl:text>
  </xsl:when>
  <xsl:when test="/collection[1]/@type='GCwines'">
   <xsl:text>7</xsl:text>
  </xsl:when>
  <xsl:when test="/collection[1]/@type='GCcoins'">
   <xsl:text>8</xsl:text>
  </xsl:when>
  <xsl:when test="/collection[1]/@type='GCgames'">
   <xsl:text>11</xsl:text>
  </xsl:when>
  <xsl:when test="/collection[1]/@type='GCboardgames'">
   <xsl:text>13</xsl:text>
  </xsl:when>
 </xsl:choose>
</xsl:variable>

<xsl:key name="fieldsByName" match="field" use="@value"/>

<xsl:template match="/">
 <tc:tellico syntaxVersion="11">
  <xsl:apply-templates select="collection" mode="top"/>
 </tc:tellico>
</xsl:template>

<xsl:template match="collection" mode="top">
 <tc:collection title="GCstar Import" type="{$coll}">
  <tc:fields>
   <tc:field name="_default"/>
   <tc:field flags="0" title="Favorite" category="Personal" format="4" type="4" name="favorite" i18n="true"/>
   <xsl:if test="item/@web or item/@webPage">
    <tc:field flags="0" title="URL" category="General" format="4" type="7" name="url" i18n="true"/>
   </xsl:if>
   <xsl:if test="(item/@location or item/@place) and $coll != 7 and $coll != 8">
     <tc:field flags="6" title="Location" category="Personal" format="4" type="1" name="location" i18n="true"/>
   </xsl:if>
   <xsl:if test="item/@composer">
    <tc:field flags="7" title="Composer" category="General" format="2" type="1" name="composer" i18n="true"/>
   </xsl:if>
   <xsl:if test="item/@producer and @type != 'GCwines'">
    <tc:field flags="7" title="Producer" category="General" format="2" type="1" name="producer" i18n="true"/>
   </xsl:if>
   <xsl:choose>
    <xsl:when test="@type='GCfilms'">
     <tc:field flags="8" title="Original Title" category="General" format="1" type="1" name="origtitle" i18n="true"/>
     <tc:field flags="0" title="Seen" category="Personal" format="4" type="4" name="seen" i18n="true"/>
    </xsl:when>
    <xsl:when test="@type='GCcoins'">
     <!-- gcstar includes way more coin grades than tellico -->
     <tc:field flags="2" title="Grade" category="General" format="4" type="3" name="grade"
               allowed="Proof-65;Proof-60;Mint State-70;Mint State-69;Mint State-68;Mint State-67;Mint State-66;Mint State-65;Mint State-64;Mint State-63;Mint State-62;Mint State-61;Mint State-60;Almost Uncirculated-58;Almost Uncirculated-55;Almost Uncirculated-53;Almost Uncirculated-50;Extremely Fine-45;Extremely Fine-40;Very Fine-35;Very Fine-30;Very Fine-25;Very Fine-20;Fine-15;Fine-12;Very Good-10;Very Good-8;Good-6;Good-4;Fair"/>
     <tc:field flags="6" title="Diameter" category="General" format="4" type="1" name="diameter" i18n="true"/>
     <tc:field flags="0" title="Estimate" category="Personal" format="4" type="1" name="estimate" i18n="true"/>
     <xsl:if test="item/metal">
      <tc:field title="Composition" flags="3" category="Composition" format="2" type="8" name="metal">
       <tc:prop name="column1">Metal</tc:prop>
       <tc:prop name="column2">Percentage</tc:prop>
       <tc:prop name="columns">2</tc:prop>
      </tc:field>
     </xsl:if>
    </xsl:when>
    <xsl:when test="@type='GCwines'">
     <tc:field title="Varietal" flags="7" category="General" format="0" type="1" name="varietal" i18n="true"/>
     <tc:field flags="0" title="Tasted" category="Personal" format="4" type="4" name="tasted" i18n="true"/>
     <tc:field flags="6" title="Distinction" category="General" format="4" type="1" name="distinction" i18n="true"/>
     <tc:field flags="6" title="Soil" category="General" format="4" type="1" name="soil" i18n="true"/>
     <tc:field flags="6" title="Alcohol" category="General" format="4" type="1" name="alcohol" i18n="true"/>
     <tc:field flags="6" title="Volume" category="General" format="4" type="1" name="volume" i18n="true"/>
     <tc:field title="Type" flags="2" category="General" format="4" type="3" name="type" i18n="yes">
      <xsl:attribute name="allowed">
       <xsl:text>Red Wine;White Wine;Sparkling Wine</xsl:text>
       <xsl:for-each select="item[not(@type=preceding-sibling::item/@type)]/@type">
        <xsl:value-of select="concat(';',.)"/>
       </xsl:for-each>
      </xsl:attribute>
     </tc:field>
    </xsl:when>
    <xsl:when test="@type='GCcomics'">
     <tc:field flags="0" title="ISBN#" category="Publishing" format="4" description="International Standard Book Number" type="1" name="isbn" i18n="true"/>
     <tc:field flags="7" title="Colorist" category="General" format="2" type="1" name="colorist" i18n="true"/>
     <tc:field flags="6" title="Format" category="Publishing" format="4" type="1" name="format" i18n="true"/>
     <tc:field flags="6" title="Category" category="Publishing" format="4" type="1" name="category" i18n="true"/>
     <tc:field flags="6" title="Collection" category="Personal" format="4" type="1" name="collection" i18n="true"/>
     <tc:field flags="0" title="Boards" category="Publishing" format="4" type="6" name="numberboards"/>
    </xsl:when>
   </xsl:choose>
   <xsl:apply-templates select="userCollection/fields/field"/>
  </tc:fields>
  <xsl:apply-templates select="item"/>
 </tc:collection>
</xsl:template>

<xsl:template match="field">
 <tc:field name="{@value}" title="{@label}" category="{@group}" i18n="true">
  <xsl:attribute name="type">
   <xsl:choose>
    <xsl:when test="@type = 'short text'"><xsl:text>1</xsl:text></xsl:when>
    <xsl:when test="@type = 'formatted'"><xsl:text>1</xsl:text></xsl:when>
    <xsl:when test="@type = 'long text'"><xsl:text>2</xsl:text></xsl:when>
    <xsl:when test="@type = 'options'"><xsl:text>3</xsl:text></xsl:when>
    <xsl:when test="@type = 'yesno'"><xsl:text>4</xsl:text></xsl:when>
    <xsl:when test="@type = 'number' and @displayas = 'text'"><xsl:text>6</xsl:text></xsl:when>
    <xsl:when test="@type = 'number' and @displayas = 'graphical'"><xsl:text>14</xsl:text></xsl:when>
    <xsl:when test="@type = 'single list'"><xsl:text>8</xsl:text></xsl:when>
    <xsl:when test="@type = 'image'"><xsl:text>10</xsl:text></xsl:when>
    <xsl:when test="@type = 'date'"><xsl:text>12</xsl:text></xsl:when>
   </xsl:choose>
  </xsl:attribute>
  <xsl:if test="string-length(@values)">
   <xsl:attribute name="allowed">
    <xsl:value-of select="translate(@values, ',', ';')"/>
   </xsl:attribute>
  </xsl:if>
  <xsl:if test="string-length(@init) and not(@type='formatted')">
   <tc:prop name="default">
    <xsl:value-of select="@init"/>
   </tc:prop>
  </xsl:if>
  <xsl:if test="string-length(@max)">
   <tc:prop name="maximum">
    <xsl:value-of select="@max"/>
   </tc:prop>
  </xsl:if>
  <xsl:if test="string-length(@min)">
   <tc:prop name="minimum">
    <xsl:value-of select="@min"/>
   </tc:prop>
  </xsl:if>
  <xsl:if test="@type='formatted'">
   <xsl:attribute name="flags">32</xsl:attribute>
   <xsl:variable name="tokens" select="str:tokenize(@init, '%')"/>
   <tc:prop name="template">
    <xsl:for-each select="$tokens[position() mod 2 = 1]">
     <xsl:value-of select="concat('%{', ., '}', following-sibling::*)"/>
    </xsl:for-each>
   </tc:prop>
  </xsl:if>
  <xsl:if test="@type='simple list'">
   <tc:prop name="columns">1</tc:prop>
  </xsl:if>
 </tc:field>
</xsl:template>

<xsl:template match="item">
 <!-- For GCstar 1.2, the XML schema changed to use attributes for all
      the 'simple' value types. The workaround here is to parse all
      the attributes and elements. For each attribute, a dummy
      element is created with the same name as the attribute, and
      that dummy element is then parsed. This way, I can use the same
      stylesheet for either format without having to repeat a lot
      of XPath expressions. -->
 <!-- simplicity, the id will either be an attribute or an element -->
 <tc:entry id="{(id|@id|@gcsautoid)[1]}">
  <xsl:apply-templates select="@*|*"/>
 </tc:entry>
</xsl:template>

<xsl:template match="item/@*[not(starts-with(local-name(), 'gcsfield'))]">
 <xsl:variable name="dummies">
  <xsl:element name="{local-name(.)}">
   <xsl:value-of select="."/>
  </xsl:element>
 </xsl:variable>
 <xsl:for-each select="exsl:node-set($dummies)/*">
  <xsl:apply-templates select="."/>
 </xsl:for-each>
</xsl:template>

<xsl:template match="item/@*[starts-with(local-name(), 'gcsfield')]">
 <xsl:element name="{local-name()}" namespace="http://periapsis.org/tellico/">
  <xsl:choose>
   <xsl:when test="key('fieldsByName', local-name())/@type = 'date'">
    <xsl:variable name="numbers" select="str:tokenize(., '/-')"/>
    <xsl:if test="count($numbers) = 3">
     <tc:year><xsl:value-of select="$numbers[3]"/></tc:year>
     <tc:month><xsl:value-of select="$numbers[2]"/></tc:month>
     <tc:day><xsl:value-of select="$numbers[1]"/></tc:day>
    </xsl:if>
   </xsl:when>
   <xsl:when test="key('fieldsByName', local-name())/@type = 'yesno'">
    <xsl:if test=". = '1'">true</xsl:if>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="."/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:element>
</xsl:template>

<!-- ignore anything not explicit -->
<xsl:template match="*"/>

<!-- the easy one matches identical local names -->
<xsl:template match="title|isbn|edition|pages|label|platform|location|vintage|quantity|soil|alcohol|collection|series|currency|diameter|estimate">
 <xsl:element name="{concat('tc:',local-name())}">
  <xsl:value-of select="."/>
 </xsl:element>
</xsl:template>

<xsl:template match="original">
 <tc:origtitle><xsl:value-of select="."/></tc:origtitle>
</xsl:template>

<xsl:template match="author|authors|language|genre|artist|composer|producer|developer|grapes|writer|illustrator|colourist|numberboards">
 <xsl:variable name="tag">
  <xsl:choose>
   <xsl:when test="local-name() = 'authors'">
    <xsl:text>author</xsl:text>
   </xsl:when>
   <xsl:when test="local-name() = 'grapes'">
    <xsl:text>varietal</xsl:text>
   </xsl:when>
   <xsl:when test="local-name() = 'illustrator'">
    <xsl:text>artist</xsl:text>
   </xsl:when>
   <xsl:when test="local-name() = 'colourist'">
    <xsl:text>colorist</xsl:text>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="local-name()"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>

 <xsl:choose>
  <xsl:when test="$tag='producer' and $coll = 7">
   <tc:producer>
    <xsl:value-of select="normalize-space(.)"/>
   </tc:producer>
  </xsl:when>
  <xsl:when test="line">
   <xsl:element name="{concat('tc:',$tag,'s')}">
    <xsl:for-each select="line">
     <xsl:for-each select="str:tokenize(col[1], ',/;')">
      <xsl:element name="{concat('tc:',$tag)}">
       <xsl:attribute name="i18n">true</xsl:attribute>
       <xsl:value-of select="normalize-space(.)"/>
      </xsl:element>
     </xsl:for-each>
    </xsl:for-each>
   </xsl:element>
  </xsl:when>

  <xsl:otherwise>
   <xsl:element name="{concat('tc:',$tag,'s')}">
    <xsl:for-each select="str:tokenize(., ',/;')">
     <xsl:element name="{concat('tc:',$tag)}">
      <xsl:attribute name="i18n">true</xsl:attribute>
      <xsl:value-of select="normalize-space(.)"/>
     </xsl:element>
    </xsl:for-each>
   </xsl:element>
  </xsl:otherwise>

 </xsl:choose>
</xsl:template>

<xsl:template match="format">
 <xsl:choose>
  <xsl:when test="$coll = 2">
   <tc:binding i18n="true">
    <xsl:choose>
     <xsl:when test="contains(., 'Paperback')">
      <xsl:text>Paperback</xsl:text>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="."/>
     </xsl:otherwise>
    </xsl:choose>
   </tc:binding>
  </xsl:when>
  <xsl:when test="$coll = 3">
   <tc:medium i18n="true"><xsl:value-of select="."/></tc:medium>
  </xsl:when>
  <xsl:when test="$coll = 4">
   <tc:medium i18n="true">
    <xsl:choose>
     <xsl:when test="text()='CD'">
      <xsl:text>Compact Disc</xsl:text>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="."/>
     </xsl:otherwise>
    </xsl:choose>
   </tc:medium>
  </xsl:when>
  <xsl:when test="$coll = 6">
   <tc:format i18n="true"><xsl:value-of select="."/></tc:format>
  </xsl:when>
 </xsl:choose>
</xsl:template>

<xsl:template match="country">
 <xsl:choose>
  <xsl:when test="$coll !=6 and $coll != 7 and $coll != 8">
   <tc:nationalitys>
    <xsl:for-each select="str:tokenize(., ',/;')">
     <tc:nationality i18n="true">
      <xsl:value-of select="normalize-space(.)"/>
     </tc:nationality>
    </xsl:for-each>
   </tc:nationalitys>
  </xsl:when>
  <xsl:otherwise>
   <tc:country>
    <xsl:value-of select="."/>
   </tc:country>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="actors">
 <tc:casts>
  <xsl:if test="line">
   <xsl:for-each select="line">
    <tc:cast>
     <tc:column>
      <xsl:value-of select="col[1]"/>
     </tc:column>
     <tc:column>
      <xsl:value-of select="col[2]"/>
     </tc:column>
    </tc:cast>
   </xsl:for-each>
  </xsl:if>
  <xsl:if test="not(line)">
   <xsl:for-each select="str:tokenize(., ',/;')">
    <tc:cast>
     <!-- could have role name in parentheses -->
     <xsl:if test="contains(., '(')">
      <tc:column>
       <xsl:value-of select="normalize-space(substring-before(., '('))"/>
      </tc:column>
      <tc:column>
       <xsl:variable name="role">
        <xsl:call-template name="substring-before-last">
         <xsl:with-param name="input" select="substring-after(., '(')"/>
         <xsl:with-param name="substr" select="')'"/>
        </xsl:call-template>
       </xsl:variable>
       <xsl:value-of select="normalize-space($role)"/>
      </tc:column>
     </xsl:if>
     <xsl:if test="not(contains(., '('))">
      <tc:column>
       <xsl:value-of select="normalize-space(.)"/>
      </tc:column>
      <tc:column/>
     </xsl:if>
    </tc:cast>
   </xsl:for-each>
  </xsl:if>
 </tc:casts>
</xsl:template>

<xsl:template match="director">
 <tc:directors>
  <tc:director>
   <xsl:value-of select="."/>
  </tc:director>
 </tc:directors>
</xsl:template>

<xsl:template match="translator">
 <tc:translators>
  <tc:translator>
   <xsl:value-of select="."/>
  </tc:translator>
 </tc:translators>
</xsl:template>

<xsl:template match="audio">
 <tc:languages>
  <xsl:for-each select="line">
   <tc:language>
    <xsl:value-of select="col[1]"/>
   </tc:language>
  </xsl:for-each>
 </tc:languages>
 <tc:audio-tracks>
  <xsl:for-each select="line">
   <tc:audio-track>
    <xsl:value-of select="col[2]"/>
   </tc:audio-track>
  </xsl:for-each>
 </tc:audio-tracks>
</xsl:template>

<xsl:template match="synopsis">
 <tc:plot><xsl:value-of select="."/></tc:plot>
</xsl:template>

<xsl:template match="comment">
 <tc:comments><xsl:value-of select="."/></tc:comments>
</xsl:template>

<xsl:template match="place">
 <tc:location><xsl:value-of select="."/></tc:location>
</xsl:template>

<xsl:template match="image|boxpic">
 <tc:cover>
  <xsl:choose>
   <!-- no.png means no image -->
   <xsl:when test=". = 'images/no.png'">
   </xsl:when>
   <!-- is the image location relative or not? -->
   <xsl:when test="starts-with(., 'file://') or starts-with(., 'http') or starts-with(., '/')">
    <xsl:value-of select="."/>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="concat($baseDir,.)"/>
   </xsl:otherwise>
  </xsl:choose>
 </tc:cover>
</xsl:template>

<xsl:template match="web|webPage">
 <tc:url><xsl:value-of select="."/></tc:url>
</xsl:template>

<xsl:template match="rating">
 <xsl:if test=". &gt; 0">
  <tc:rating><xsl:value-of select="floor(. div 2)"/></tc:rating>
 </xsl:if>
</xsl:template>

<xsl:template match="age">
 <tc:certification i18n="true">
  <xsl:choose>
   <xsl:when test=". = 1">
    <xsl:text>U (USA)</xsl:text>
   </xsl:when>
   <xsl:when test=". = 2">
    <xsl:text>G (USA)</xsl:text>
   </xsl:when>
   <xsl:when test=". &lt; 6">
    <xsl:text>PG (USA)</xsl:text>
   </xsl:when>
   <xsl:when test=". &lt; 14">
    <xsl:text>PG-13 (USA)</xsl:text>
   </xsl:when>
   <xsl:when test=". &lt; 19">
    <xsl:text>R (USA)</xsl:text>
   </xsl:when>
  </xsl:choose>
 </tc:certification>
</xsl:template>

<xsl:template match="time">
 <tc:running-time>
  <xsl:value-of select="translate(.,translate(.,'0123456789',''),'')"/>
 </tc:running-time>
</xsl:template>

<xsl:template match="video">
 <tc:format i18n="true">
  <xsl:value-of select="translate(.,'abcdefghijklmnopqrstuvwxyz',
                                    'ABCDEFGHIJKLMNOPQRSTUCWXYZ')"/>
 </tc:format>
</xsl:template>

<xsl:template match="borrower">
 <xsl:if test="string-length(.) &gt; 0 and . != 'none'">
  <tc:loaned>true</tc:loaned>
 </xsl:if>
</xsl:template>

<xsl:template match="read">
 <xsl:if test=". &gt; 0">
  <tc:read>true</tc:read>
 </xsl:if>
</xsl:template>

<xsl:template match="seen">
 <xsl:if test=". &gt; 0">
  <tc:seen>true</tc:seen>
 </xsl:if>
</xsl:template>

<xsl:template match="favourite">
 <xsl:if test=". &gt; 0">
  <tc:favorite>true</tc:favorite>
 </xsl:if>
</xsl:template>

<xsl:template match="publication|publishdate">
 <tc:pub_year>
  <xsl:call-template name="year">
   <xsl:with-param name="value" select="."/>
  </xsl:call-template>
 </tc:pub_year>
</xsl:template>

<xsl:template match="aquisition|purchasedate">
 <tc:pur_date><xsl:value-of select="."/></tc:pur_date>
</xsl:template>

<xsl:template match="added">
 <xsl:if test="not(../acquisition)">
  <tc:pur_date><xsl:value-of select="."/></tc:pur_date>
 </xsl:if>
 <xsl:variable name="numbers" select="str:tokenize(., '/-')"/>
 <xsl:if test="count($numbers) = 3">
  <tc:cdate calendar="gregorian" >
   <tc:year><xsl:value-of select="$numbers[3]"/></tc:year>
   <tc:month><xsl:value-of select="$numbers[2]"/></tc:month>
   <tc:day><xsl:value-of select="$numbers[1]"/></tc:day>
  </tc:cdate>
  <tc:mdate calendar="gregorian" >
   <tc:year><xsl:value-of select="$numbers[3]"/></tc:year>
   <tc:month><xsl:value-of select="$numbers[2]"/></tc:month>
   <tc:day><xsl:value-of select="$numbers[1]"/></tc:day>
  </tc:mdate>
 </xsl:if>
</xsl:template>

<xsl:template match="serie">
 <tc:series><xsl:value-of select="."/></tc:series>
</xsl:template>

<xsl:template match="comments">
 <tc:comments>
  <xsl:if test="$coll = 2 and ../description">
   &lt;br/&gt;
   <xsl:value-of select="../description"/>
   &lt;br/&gt;
  </xsl:if>
  <xsl:value-of select="."/>
 </tc:comments>
</xsl:template>

<xsl:template match="description|tasting">
 <xsl:if test="$coll != 2">
  <tc:description><xsl:value-of select="."/></tc:description>
 </xsl:if>
</xsl:template>

<xsl:template match="volume">
 <xsl:if test="$coll != 6">
  <tc:volume><xsl:value-of select="."/></tc:volume>
 </xsl:if>
 <xsl:if test="$coll = 6">
  <tc:issue><xsl:value-of select="."/></tc:issue>
 </xsl:if>
</xsl:template>

<xsl:template match="year|date|release|released">
 <tc:year>
  <xsl:call-template name="year">
   <xsl:with-param name="value" select="."/>
  </xsl:call-template>
 </tc:year>
</xsl:template>

<xsl:template match="tracks">
 <tc:tracks>
  <xsl:for-each select="line">
   <tc:track>
    <tc:column>
     <xsl:value-of select="col[2]"/>
    </tc:column>
    <tc:column>
     <xsl:value-of select="(../../artist|../../@artist)[1]"/>
    </tc:column>
    <tc:column>
     <xsl:value-of select="col[3]"/>
    </tc:column>
   </tc:track>
  </xsl:for-each>
 </tc:tracks>
</xsl:template>

<xsl:template match="name">
 <tc:title><xsl:value-of select="."/></tc:title>
</xsl:template>

<xsl:template match="completion">
 <xsl:if test=". &gt; 99">
  <tc:completed>true</tc:completed>
 </xsl:if>
</xsl:template>

<xsl:template match="editor|publisher|publishedby">
 <tc:publishers>
  <xsl:for-each select="str:tokenize(., ',/;')">
   <tc:publisher>
    <xsl:value-of select="normalize-space(.)"/>
   </tc:publisher>
  </xsl:for-each>
 </tc:publishers>
</xsl:template>

<xsl:template match="tags">
 <tc:keywords>
  <xsl:for-each select="line">
   <tc:keyword>
    <xsl:value-of select="col[1]"/>
   </tc:keyword>
  </xsl:for-each>
 </tc:keywords>
</xsl:template>

<xsl:template match="subt">
 <tc:subtitles>
  <xsl:for-each select="line">
   <tc:subtitle>
    <xsl:value-of select="col[1]"/>
   </tc:subtitle>
  </xsl:for-each>
 </tc:subtitles>
</xsl:template>

<xsl:template match="metal">
 <tc:metals>
  <xsl:for-each select="line">
   <tc:metal>
    <tc:column>
     <xsl:value-of select="col[1]"/>
    </tc:column>
   </tc:metal>
  </xsl:for-each>
 </tc:metals>
</xsl:template>

<xsl:template match="value">
 <tc:denomination><xsl:value-of select="."/></tc:denomination>
</xsl:template>

<xsl:template match="purchaseprice|cost">
 <tc:pur_price><xsl:value-of select="."/></tc:pur_price>
</xsl:template>

<xsl:template match="front">
 <tc:obverse><xsl:value-of select="."/></tc:obverse>
</xsl:template>

<xsl:template match="back">
 <tc:reverse><xsl:value-of select="."/></tc:reverse>
</xsl:template>

<xsl:template match="designedby">
 <tc:designers>
  <xsl:for-each select="str:tokenize(., ',/;')">
   <tc:designer>
    <xsl:value-of select="normalize-space(.)"/>
   </tc:designer>
  </xsl:for-each>
 </tc:designers>
</xsl:template>

<xsl:template match="players">
 <tc:num-players>
  <!-- need to parse ranges, like 2-6 -->
  <xsl:for-each select="str:tokenize(., ',/;')">
   <tc:num-player>
    <xsl:value-of select="normalize-space(.)"/>
   </tc:num-player>
  </xsl:for-each>
 </tc:num-players>
</xsl:template>

<xsl:template match="mechanics">
 <tc:mechanisms>
  <xsl:for-each select="line">
   <tc:mechanism>
    <xsl:value-of select="col[1]"/>
   </tc:mechanism>
  </xsl:for-each>
 </tc:mechanisms>
</xsl:template>

<xsl:template match="category">
 <xsl:if test="$coll = 6">
  <tc:category><xsl:value-of select="."/></tc:category>
 </xsl:if>
 <xsl:if test="$coll != 6">
  <tc:genres>
   <xsl:for-each select="line">
    <tc:genre>
     <xsl:value-of select="col[1]"/>
    </tc:genre>
   </xsl:for-each>
  </tc:genres>
 </xsl:if>
</xsl:template>

<!-- coins -->
<xsl:template match="condition">
<!-- by default, Tellico includes
        "Proof-65,Proof-60,Mint State-65,Mint State-60,"
        "Almost Uncirculated-55,Almost Uncirculated-50,"
        "Extremely Fine-40,Very Fine-30,Very Fine-20,Fine-12,"
        "Very Good-8,Good-4,Fair" -->
<!-- GCStar doesn't appear to include proof grades -->
 <tc:grade>
  <xsl:choose>
   <xsl:when test=".='70'">Mint State-70</xsl:when>
   <xsl:when test=".='69'">Mint State-69</xsl:when>
   <xsl:when test=".='68'">Mint State-68</xsl:when>
   <xsl:when test=".='67'">Mint State-67</xsl:when>
   <xsl:when test=".='66'">Mint State-66</xsl:when>
   <xsl:when test=".='65'">Mint State-65</xsl:when>
   <xsl:when test=".='64'">Mint State-64</xsl:when>
   <xsl:when test=".='63'">Mint State-63</xsl:when>
   <xsl:when test=".='62'">Mint State-62</xsl:when>
   <xsl:when test=".='61'">Mint State-61</xsl:when>
   <xsl:when test=".='60'">Mint State-60</xsl:when>
   <xsl:when test=".='58'">Almost Uncirculated-58</xsl:when>
   <xsl:when test=".='55'">Almost Uncirculated-55</xsl:when>
   <xsl:when test=".='53'">Almost Uncirculated-53</xsl:when>
   <xsl:when test=".='50'">Almost Uncirculated-50</xsl:when>
   <xsl:when test=".='45'">Extremely Fine-45</xsl:when>
   <xsl:when test=".='40'">Extremely Fine-40</xsl:when>
   <xsl:when test=".='35'">Very Fine-35</xsl:when>
   <xsl:when test=".='30'">Very Fine-30</xsl:when>
   <xsl:when test=".='25'">Very Fine-25</xsl:when>
   <xsl:when test=".='20'">Very Fine-20</xsl:when>
   <xsl:when test=".='15'">Fine-15</xsl:when>
   <xsl:when test=".='12'">Fine-12</xsl:when>
   <xsl:when test=".='10'">Very Good-10</xsl:when>
   <xsl:when test=".='8'">Very Good-8</xsl:when>
   <xsl:when test=".='6'">Good-6</xsl:when>
   <xsl:when test=".='4'">Good-4</xsl:when>
   <xsl:when test=".&lt;4">Fair</xsl:when>
  </xsl:choose>
 </tc:grade>
 <!-- GCstar defaults to PCGS -->
 <tc:service>PCGS</tc:service>
</xsl:template>

<xsl:template match="designation">
 <tc:appellation><xsl:value-of select="."/></tc:appellation>
</xsl:template>

<xsl:template match="type">
 <tc:type i18n="true">
  <xsl:choose>
   <xsl:when test="contains(.,'red')">Red Wine</xsl:when>
   <xsl:when test="contains(.,'white')">White Wine</xsl:when>
   <xsl:when test="contains(.,'champagne') or contains(.,'sparking')">Sparkling Wine</xsl:when>
   <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
  </xsl:choose>
 </tc:type>
</xsl:template>

<xsl:template match="medal">
 <tc:distinction><xsl:value-of select="."/></tc:distinction>
</xsl:template>

<xsl:template match="bottlelabel">
 <tc:label><xsl:value-of select="."/></tc:label>
</xsl:template>

<xsl:template match="gift">
 <xsl:if test="string-length(.) &gt; 0 and . != 'false' and . != '0'">
  <tc:gift>true</tc:gift>
 </xsl:if>
</xsl:template>

<xsl:template match="tasted">
 <xsl:if test="string-length(.) &gt; 0 and . != 'false' and . != '0'">
  <tc:tasted>true</tc:tasted>
 </xsl:if>
</xsl:template>

<xsl:template match="signing">
 <xsl:if test="string-length(.) &gt; 0 and . != 'false' and . != '0'">
  <tc:signed>true</tc:signed>
 </xsl:if>
</xsl:template>

<xsl:template match="front">
 <tc:obverse><xsl:value-of select="."/></tc:obverse>
</xsl:template>

<xsl:template match="back">
 <tc:reverse><xsl:value-of select="."/></tc:reverse>
</xsl:template>

<xsl:template match="*[starts-with(local-name(), 'gcsfield')]">
  <xsl:choose>
   <xsl:when test="key('fieldsByName', local-name())/@type = 'single list'">
    <xsl:element name="{concat(local-name(), 's')}">
     <xsl:for-each select="line">
      <xsl:element name="{local-name(..)}">
       <tc:column>
        <xsl:value-of select="col"/>
       </tc:column>
      </xsl:element>
     </xsl:for-each>
    </xsl:element>
   </xsl:when>
   <xsl:otherwise>
    <xsl:element name="{local-name()}">
     <xsl:value-of select="."/>
    </xsl:element>
   </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="substring-before-last">
 <xsl:param name="input"/>
 <xsl:param name="substr"/>
 <xsl:if test="$substr and contains($input, $substr)">
  <xsl:variable name="temp" select="substring-after($input, $substr)"/>
  <xsl:value-of select="substring-before($input, $substr)"/>
  <xsl:if test="contains($temp, $substr)">
   <xsl:value-of select="$substr"/>
   <xsl:call-template name="substring-before-last">
    <xsl:with-param name="input" select="$temp"/>
    <xsl:with-param name="substr" select="$substr"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:if>
</xsl:template>

<xsl:template name="year">
 <xsl:param name="value"/>
 <!-- want to find a 4-digit number to treat as the year -->
 <xsl:variable name="nondigits" select="translate($value,'0123456789','')"/>
  <xsl:choose>

   <xsl:when test="string-length($nondigits) = 0">
    <xsl:if test="string-length($value) = 4">
     <xsl:value-of select="."/>
    </xsl:if>
   </xsl:when>

   <xsl:otherwise>
    <xsl:for-each select="str:tokenize($value,$nondigits)">
     <xsl:if test="string-length() = 4">
      <xsl:value-of select="."/>
     </xsl:if>
    </xsl:for-each>
   </xsl:otherwise>

  </xsl:choose>
</xsl:template>

</xsl:stylesheet>