forked from oeuvres/teinte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalix.xsl
105 lines (100 loc) · 4.24 KB
/
alix.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
LGPL http://www.gnu.org/licenses/lgpl.html
© 2016 Frederic.Glorieux@fictif.org
Split a single TEI book in a multi-pages site
-->
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:alix="java:com.github.oeuvres.lucene.Alix"
exclude-result-prefixes="tei alix"
>
<xsl:import href="tei2html.xsl"/>
<!-- Name of file, provided by caller -->
<xsl:param name="filename"/>
<!-- Options for the html field, be careful if not congruent -->
<xsl:variable name="text-opts">IdfpoPV</xsl:variable>
<!-- Options for a pure store field with no search and no effect on docFreq, useful for tocs, index… -->
<xsl:variable name="html-opts">S</xsl:variable>
<!-- Name of this xsl -->
<xsl:variable name="this">tei2lucene.xsl</xsl:variable>
<xsl:output indent="yes" encoding="UTF-8" method="xml" />
<xsl:key name="split" match="
tei:*[self::tei:div or self::tei:div1 or self::tei:div2][normalize-space(.) != ''][@type][
contains(@type, 'article')
or contains(@type, 'chapter')
or contains(@subtype, 'split')
or contains(@type, 'act')
or contains(@type, 'poem')
or contains(@type, 'letter')
]
| tei:group/tei:text
| tei:TEI/tei:text/tei:*/tei:*[self::tei:div or self::tei:div1 or self::tei:group or self::tei:titlePage or self::tei:castList][normalize-space(.) != '']"
use="generate-id(.)"/>
<!-- Maybe used for instrospection -->
<xsl:template match="/*">
<!-- Table des matières -->
<xsl:value-of select="alix:docNew()"/>
<xsl:call-template name="alix:metas"/>
<xsl:variable name="code" select="'toc'"/>
<xsl:value-of select="alix:field('href', concat($filename, '/', $code))"/>
<xsl:value-of select="alix:field('code', $code)"/>
<xsl:variable name="html">
<xsl:call-template name="toc"/>
</xsl:variable>
<xsl:value-of select="alix:field('html', $html, $html-opts)"/>
<xsl:value-of select="alix:docWrite()"/>
<!-- Page de titre -->
<xsl:value-of select="alix:docNew()"/>
<xsl:call-template name="alix:metas"/>
<xsl:variable name="html">
<xsl:apply-templates select="/*/tei:teiHeader"/>
</xsl:variable>
<xsl:variable name="code" select="'titlePage'"/>
<xsl:value-of select="alix:field('href', concat($filename, '/', $code))"/>
<xsl:value-of select="alix:field('code', $code)"/>
<xsl:value-of select="alix:field('html', $html, $html-opts)"/>
<xsl:value-of select="alix:docWrite()"/>
<!-- metas -->
<!-- On parse -->
<xsl:apply-templates select="*" mode="alix"/>
</xsl:template>
<xsl:template name="alix:metas">
<xsl:value-of select="alix:field('title', $doctitle, 'ITS')"/>
<xsl:value-of select="alix:field('date', $docdate, '#')"/>
<xsl:value-of select="alix:field('byline', $byline, 'ITS')"/>
<xsl:variable name="head">
<xsl:apply-templates select="tei:head[1]" mode="title"/>
</xsl:variable>
<xsl:value-of select="alix:field('head', $head, 'ITS')"/>
</xsl:template>
<xsl:template match="tei:teiHeader" mode="alix"/>
<xsl:template match="*" mode="alix">
<xsl:apply-templates select="*" mode="alix"/>
</xsl:template>
<xsl:template match="tei:div | tei:div0 | tei:div1 | tei:div2 | tei:div3 | tei:div4 | tei:div5 | tei:div6 | tei:div7 " mode="alix">
<xsl:choose>
<xsl:when test="not(tei:p)">
<xsl:apply-templates select="*" mode="alix"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="code">
<xsl:call-template name="id"/>
</xsl:variable>
<xsl:value-of select="alix:docNew()"/>
<xsl:call-template name="alix:metas"/>
<xsl:value-of select="alix:field('href', concat($filename, '/', $code))"/>
<xsl:value-of select="alix:field('code', $code)"/>
<xsl:value-of select="alix:field('type', 'chapter')"/>
<xsl:variable name="html">
<xsl:apply-templates select="."/>
</xsl:variable>
<xsl:value-of select="alix:field('html', $html, $html-opts)"/>
<xsl:value-of select="alix:field('text', $html, $text-opts)"/>
<xsl:value-of select="alix:docWrite()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:transform>