-
Notifications
You must be signed in to change notification settings - Fork 0
/
htm-tpl-apparatus.xsl
133 lines (127 loc) · 6.45 KB
/
htm-tpl-apparatus.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
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:t="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="t"
version="2.0">
<!-- Apparatus creation: look in tpl-apparatus.xsl for documentation -->
<xsl:include href="tpl-apparatus.xsl"/>
<!-- Apparatus framework -->
<xsl:template name="tpl-apparatus">
<!-- An apparatus is only created if one of the following is true -->
<xsl:if test=".//t:choice | .//t:subst | .//t:app | .//t:g[@type='apostrophe'] |
.//t:hi[@rend = 'diaeresis' or @rend = 'grave' or @rend = 'acute' or @rend = 'asper' or @rend = 'lenis' or @rend = 'circumflex'] |
.//t:del[@rend='slashes' or @rend='cross-strokes'] | .//t:milestone[@rend = 'box']">
<h2>Apparatus</h2>
<div id="apparatus">
<xsl:variable name="apparatus">
<!-- An entry is created for-each of the following instances
* choice, subst or app not nested in another;
* hi not nested in the app part of an app;
* del or milestone.
-->
<xsl:for-each select="(.//t:choice | .//t:subst | .//t:app)[not(ancestor::t:*[local-name()=('choice','subst','app')])] | .//t:g[@type='apostrophe'] |
.//t:hi[@rend=('diaeresis','grave','acute','asper','lenis','circumflex')][not(ancestor::t:*[local-name()=('orig','reg','sic','corr','lem','rdg')
or self::t:del[@rend='corrected']
or self::t:add[@place='inline']][1][local-name()=('reg','corr','rdg')
or self::t:del[@rend='corrected']]
or ancestor::t:hi)] |
.//t:del[@rend='slashes' or @rend='cross-strokes'] | .//t:milestone[@rend = 'box']">
<app>
<!-- Found in tpl-apparatus.xsl -->
<xsl:call-template name="ddbdp-app">
<xsl:with-param name="apptype">
<xsl:choose>
<xsl:when test="self::t:choice[child::t:orig and child::t:reg]">
<xsl:text>origreg</xsl:text>
</xsl:when>
<xsl:when test="self::t:choice[child::t:sic and child::t:corr]">
<xsl:text>siccorr</xsl:text>
</xsl:when>
<xsl:when test="self::t:subst">
<xsl:text>subst</xsl:text>
</xsl:when>
<xsl:when test="self::t:app[@type='alternative']">
<xsl:text>appalt</xsl:text>
</xsl:when>
<xsl:when test="self::t:app[@type='editorial'][starts-with(t:lem/@resp,'BL ')]">
<xsl:text>appbl</xsl:text>
</xsl:when>
<xsl:when test="self::t:app[@type='editorial'][starts-with(t:lem/@resp,'PN ')]">
<xsl:text>apppn</xsl:text>
</xsl:when>
<xsl:when test="self::t:app[@type='editorial']">
<xsl:text>apped</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</app>
</xsl:for-each>
</xsl:variable>
<!-- XSL for-each-group effectively suppresses any duplicate apparati generated due to sibling triggers. -->
<xsl:for-each-group select="$apparatus/*:app" group-by=".">
<xsl:copy-of select="node()"/>
</xsl:for-each-group>
</div>
</xsl:if>
</xsl:template>
<!-- called from tpl-apparatus.xsl -->
<xsl:template name="lbrk-app">
<br/>
</xsl:template>
<!-- Used in htm-{element} and above to add linking to and from apparatus -->
<xsl:template name="app-link">
<!-- location defines the direction of linking -->
<xsl:param name="location"/>
<!-- Does not produce links for translations -->
<xsl:if test="not(ancestor::t:div[@type = 'translation'])">
<!-- Only produces a link if it is not nested in an element that would be in apparatus -->
<xsl:if test="not((local-name() = 'choice' or local-name() = 'subst' or local-name() = 'app')
and (ancestor::t:choice or ancestor::t:subst or ancestor::t:app))">
<xsl:variable name="app-num">
<xsl:value-of select="name()"/>
<xsl:number level="any" format="01"/>
</xsl:variable>
<xsl:call-template name="generate-app-link">
<xsl:with-param name="location" select="$location"/>
<xsl:with-param name="app-num" select="$app-num"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
<!-- Called by app-link to generate the actual HTML, so other projects can override this template for their own style -->
<xsl:template name="generate-app-link">
<xsl:param name="location"/>
<xsl:param name="app-num"/>
<xsl:choose>
<xsl:when test="$location = 'text'">
<a>
<xsl:attribute name="href">
<xsl:text>#to-app-</xsl:text>
<xsl:value-of select="$app-num"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:text>from-app-</xsl:text>
<xsl:value-of select="$app-num"/>
</xsl:attribute>
<xsl:text>(*)</xsl:text>
</a>
</xsl:when>
<!-- Output at begining of each apparatus entry, suppresses duplicate output at end of apparatus. if $location='apparatus' -->
<xsl:when test="$location = 'apparatus-link-back'">
<a>
<xsl:attribute name="id">
<xsl:text>to-app-</xsl:text>
<xsl:value-of select="$app-num"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:text>#from-app-</xsl:text>
<xsl:value-of select="$app-num"/>
</xsl:attribute>
<xsl:text>^</xsl:text>
</a>
<xsl:text> </xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>