gfl-indexer.xslt 3.36 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
33
34
35
36
37
38
39
40
   </xsl:template>

   
   <!--###########   Header   #######################-->
   
   <xsl:template match="teiHeader">
      <xsl:apply-templates select="fileDesc" />
   </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
44
   </xsl:template>
   
   <xsl:template match="title[@type='short']">
Dennis Neumann's avatar
Dennis Neumann committed
45
      <field name="short_title">
Dennis Neumann's avatar
Dennis Neumann committed
46
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
47
48
49
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
50
   <xsl:template match="title[@type='desc']">
Dennis Neumann's avatar
Dennis Neumann committed
51
      <field name="title">
Dennis Neumann's avatar
Dennis Neumann committed
52
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
53
54
55
      </field>
   </xsl:template>

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

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

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

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

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

92

Dennis Neumann's avatar
Dennis Neumann committed
93
94
95
96
97
98
99
100
101
   <!--###################   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>
102
103
   </xsl:template>

104
   <xsl:template match="lb" mode="text_only">
105
106
      <xsl:text> </xsl:text>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
107

108
   <xsl:template match="note[@type='com']" mode="text_only">
109
110
   </xsl:template>

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