gfl-indexer.xslt 3.87 KB
Newer Older
Dennis Neumann's avatar
Dennis Neumann committed
1
2
3
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
5
6
7
   xpath-default-namespace="http://www.tei-c.org/ns/1.0" xmlns:gfl="http://sub.gfl.de"
   xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="gfl saxon xs">

   <xsl:output method="xml" indent="yes" />
8
   
9
10
11
12

   <xsl:template match="/">
      <add>
         <doc>
Dennis Neumann's avatar
Dennis Neumann committed
13
            <xsl:apply-templates select="TEI" />
14
15
16
         </doc>
      </add>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
17

Dennis Neumann's avatar
Dennis Neumann committed
18
19
20
21
22
23
   <xsl:template match="TEI">
      <xsl:apply-templates select="teiHeader | text" />
   </xsl:template>

 
   <xsl:template match="text()" mode="#all">
24
25
26
      <xsl:variable name="current" select="normalize-space(.)" />
      <xsl:variable name="next" select="normalize-space(following::text()[1])" />
      <xsl:value-of select="if ($current='' and $next='') then '' else replace(., '\s+', ' ')" />
Dennis Neumann's avatar
Dennis Neumann committed
27
28
29
30
31
32
   </xsl:template>

   
   <!--###########   Header   #######################-->
   
   <xsl:template match="teiHeader">
Dennis Neumann's avatar
Dennis Neumann committed
33
      <xsl:apply-templates select="fileDesc | profileDesc/textClass" />
Dennis Neumann's avatar
Dennis Neumann committed
34
35
36
37
38
39
40
   </xsl:template>
   
   <xsl:template match="fileDesc">
      <xsl:apply-templates select="titleStmt/title" />
      <xsl:apply-templates select="titleStmt/title[@type='desc']/name" />
      <xsl:apply-templates select="titleStmt/title[@type='desc']/date[@type='orn']" />
      <xsl:apply-templates select="titleStmt/author/name" />
41
      <xsl:apply-templates select="sourceDesc" />
Dennis Neumann's avatar
Dennis Neumann committed
42
43
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
44
45
46
47
   <xsl:template match="profileDesc/textClass">
      <xsl:apply-templates select="keywords/term" />
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
48
   <xsl:template match="title[@type='short']">
Dennis Neumann's avatar
Dennis Neumann committed
49
      <field name="short_title">
Dennis Neumann's avatar
Dennis Neumann committed
50
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
51
52
53
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
54
   <xsl:template match="title[@type='desc']">
Dennis Neumann's avatar
Dennis Neumann committed
55
      <field name="title">
Dennis Neumann's avatar
Dennis Neumann committed
56
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
57
58
59
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
60
   <xsl:template match="title/name[@type='place' and @subtype='orn']">
Dennis Neumann's avatar
Dennis Neumann committed
61
62
63
64
65
      <field name="origin_place">
         <xsl:apply-templates select="*|text()" mode="text_only" />
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
66
   <xsl:template match="title/name[@type='place' and @subtype='dtn']">
Dennis Neumann's avatar
Dennis Neumann committed
67
      <field name="destination_place">
Dennis Neumann's avatar
Dennis Neumann committed
68
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
69
70
71
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
72
   <xsl:template match="title/name[@type='person' and @subtype='rcp']">
Dennis Neumann's avatar
Dennis Neumann committed
73
      <field name="recipient">
Dennis Neumann's avatar
Dennis Neumann committed
74
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
75
76
77
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
78
   <xsl:template match="title/date[@type='orn']">
Dennis Neumann's avatar
Dennis Neumann committed
79
80
81
82
83
      <field name="origin_date">
         <xsl:value-of select="@when" />
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
84
   <xsl:template match="author/name[@type='person' and @subtype='aut']">
Dennis Neumann's avatar
Dennis Neumann committed
85
      <field name="author">
Dennis Neumann's avatar
Dennis Neumann committed
86
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
87
88
      </field>
   </xsl:template>
89
90
91
92
93
94
   
   <xsl:template match="sourceDesc">
      <field name="source_description">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
95

Dennis Neumann's avatar
Dennis Neumann committed
96
97
98
99
100
101
102
103
104
105
106
107
108
   <xsl:template match="textClass/keywords[@scheme='#gnd']/term">
      <field name="gnd_keyword">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>

   <xsl:template match="textClass/keywords[@scheme='free']/term">
      <field name="free_keyword">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>


109

Dennis Neumann's avatar
Dennis Neumann committed
110
111
112
113
114
115
116
117
118
   <!--###################   text/body   ##########################-->

   <xsl:template match="text">
      <field name="id">
         <xsl:value-of select="@xml:id" />
      </field>
      <field name="fulltext">
         <xsl:apply-templates select="body/*" mode="text_only" />
      </field>
119
120
   </xsl:template>

121
   <xsl:template match="lb" mode="text_only">
122
123
      <xsl:text> </xsl:text>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
124

125
   <xsl:template match="note[@type='com']" mode="text_only">
126
127
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
128
</xsl:stylesheet>