-
Notifications
You must be signed in to change notification settings - Fork 4
/
generate-search.xpl
180 lines (143 loc) · 6.14 KB
/
generate-search.xpl
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
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:f="http://www.faustedition.net/ns"
xmlns:pxf="http://exproc.org/proposed/steps/file"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:j="http://www.ibm.com/xmlns/prod/2009/jsonx"
xmlns:l="http://xproc.org/library" version="1.0" name="main" type="f:generate-search">
<p:input port="source"/>
<p:input port="parameters" kind="parameter"/>
<p:output port="result"/>
<p:option name="paths" select="resolve-uri('paths.xml')"/>
<p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl"/>
<p:import href="apply-edits.xpl"/>
<!-- Parameter laden -->
<p:xslt name="config" template-name="param">
<p:input port="source"><p:empty/></p:input>
<p:input port="stylesheet"><p:document href="xslt/config.xsl"/></p:input>
<p:with-param name="path_config" select="$paths"></p:with-param>
</p:xslt>
<p:identity name="source"><p:input port="source"><p:pipe port="source" step="main"/></p:input></p:identity>
<p:group name="body">
<p:variable name="apphtml" select="//c:param[@name='apphtml']/@value"><p:pipe port="result" step="config"></p:pipe></p:variable>
<p:variable name="builddir" select="resolve-uri(//c:param[@name='builddir']/@value)"><p:pipe port="result" step="config"/></p:variable>
<cx:message log="info">
<p:with-option name="message" select="'Adding generated markup to transcripts ...'"/>
</cx:message>
<!-- Zunächst sortieren wir die Transkripteliste chronologisch -->
<p:xslt name="sort-transcripts">
<p:input port="stylesheet"><p:inline>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:import href="xslt/utils.xsl"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:perform-sort select="*">
<xsl:sort select="number(f:get-wit-index(@sigil_t))"/>
</xsl:perform-sort>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
</p:inline></p:input>
<p:input port="parameters"><p:pipe port="result" step="config"/></p:input>
</p:xslt>
<!--
Wir iterieren über die Transkripteliste, die vom Skript in collect-metadata.xpl generiert wird.
Für die Variantengenerierung berücksichtigen wir dabei jedes dort verzeichnete Transkript.
-->
<p:for-each>
<p:iteration-source select="//f:textTranscript"/>
<p:variable name="transcriptFile" select="/f:textTranscript/@href"/>
<p:variable name="transcriptURI" select="/f:textTranscript/@uri"/>
<p:variable name="sigil_t" select="/f:textTranscript/@sigil_t"/>
<p:variable name="documentURI" select="/f:textTranscript/@document"/>
<p:variable name="type" select="/f:textTranscript/@type"/>
<p:variable name="sigil" select="/f:textTranscript/f:idno[1]/text()"/>
<p:variable name="sigil-type" select="/f:textTranscript/f:idno[1]/@type"/>
<p:variable name="number" select="/f:textTranscript/@number"/>
<!--<cx:message>
<p:with-option name="message" select="concat('Adding generated markup to ', $sigil, ' (', $transcriptFile, ')')"/>
</cx:message>-->
<!-- Das Transkript wird geladen ... -->
<p:load>
<p:with-option name="href" select="$transcriptFile"/>
</p:load>
<p:xslt name="add-metadata">
<p:input port="stylesheet">
<p:document href="xslt/add-metadata.xsl"/>
</p:input>
<p:with-param name="documentURI" select="$documentURI"/>
<p:with-param name="type" select="$type"/>
<p:with-param name="transcriptURI" select="$transcriptURI"/>
<p:with-param name="number" select="$number"/>
<p:with-param name="sigil_t" select="$sigil_t"/>
<p:input port="parameters">
<p:pipe port="result" step="config"/>
</p:input>
</p:xslt>
<p:choose>
<p:when test="$type = 'lesetext'">
<p:identity/>
</p:when>
<p:otherwise>
<!-- Wir suchen die Transkriptnummern aus den <pb>s heraus, bzw. versuchen das -->
<p:xslt name="pbs">
<p:input port="stylesheet">
<p:document href="xslt/resolve-pb.xsl"/>
</p:input>
<p:with-param name="documentURI" select="$documentURI"></p:with-param>
<p:input port="parameters">
<p:pipe port="result" step="config"/>
</p:input>
</p:xslt>
</p:otherwise>
</p:choose>
<p:identity name="prepared-xml"/>
<!-- erste Kopie: Unnormalisierte Zeichen zum Weiterarbeiten -->
<p:store>
<p:with-option name="href" select="resolve-uri(concat('prepared/textTranscript/', $sigil_t, '.xml'), $builddir)"/>
</p:store>
<p:identity><p:input port="source"><p:pipe port="result" step="prepared-xml"/></p:input></p:identity>
<!-- Ansonsten nur Zeichen normalisieren -->
<p:xslt name="normalize-characters">
<p:input port="stylesheet">
<p:document href="xslt/normalize-characters.xsl"/>
</p:input>
<p:input port="parameters">
<p:pipe port="result" step="config"/>
</p:input>
</p:xslt>
<!-- Notes aus dem Lesetext für die Suche wieder rauswerfen -->
<p:choose>
<p:when test="$sigil_t = 'faust'">
<p:delete match="tei:note[@type='textcrit']"/>
</p:when>
<p:otherwise>
<p:identity/>
</p:otherwise>
</p:choose>
<!-- For search, choice[sic and corr] → sic https://github.com/faustedition/faust-gen-html/issues/650 -->
<p:xslt>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="@*, node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="tei:choice[tei:sic and tei:corr]">
<xsl:apply-templates select="tei:sic/node()"/>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
</p:xslt>
<!-- zweite Kopie: Normalisierte Zeichen für die Suche -->
<p:store>
<p:with-option name="href" select="resolve-uri(concat('search/textTranscript/', $sigil_t, '.xml'), $builddir)"/>
</p:store>
</p:for-each>
</p:group>
<p:identity><p:input port="source"><p:pipe port="result" step="source"></p:pipe></p:input></p:identity>
</p:declare-step>