blob: 87f28185750ffaaab40c2d9a3b61a3d4034fedd5 (
plain)
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
|
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:exsl="http://exslt.org/common"
xmlns:set="http://exslt.org/sets"
exclude-result-prefixes="exsl set"
version="1.0">
<!-- ********************************************************************
$Id$
********************************************************************
This file is part of the DocBook XSL Stylesheet distribution.
See ../README or http://docbook.sf.net/ for copyright
copyright and other information.
******************************************************************** -->
<!-- This module contains templates that match against FO nodes. It is used
to post-process result tree fragments for some sorts of cleanup.
These templates can only ever be fired by a processor that supports
exslt:node-set(). -->
<!-- ==================================================================== -->
<!-- insert.fo.fnum mode templates insert a particular RTF at the beginning
of the first paragraph in the primary RTF. In fact, they are inserting
a footnote-number, so we tinker a few other things too, like spacing and
font-sizes. -->
<xsl:template match="/" mode="insert.fo.fnum">
<xsl:param name="mark" select="'?'"/>
<xsl:apply-templates mode="insert.fo.fnum">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*" mode="insert.fo.fnum">
<xsl:param name="mark" select="'?'"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="insert.fo.fnum">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="fo:block" mode="insert.fo.fnum">
<xsl:param name="mark" select="'?'"/>
<xsl:copy>
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="starts-with(name(.), 'space-before')"/>
<xsl:when test="starts-with(name(.), 'space-after')"/>
<xsl:when test="starts-with(name(.), 'font-size')"/>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:if test="not(preceding::fo:block)">
<xsl:copy-of select="$mark"/>
</xsl:if>
<xsl:apply-templates mode="insert.fo.fnum">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.fnum">
<xsl:param name="mark" select="'?'"/>
<xsl:copy/>
</xsl:template>
<!-- ==================================================================== -->
<!-- insert.fo.block mode templates insert a particular RTF at the beginning
of the first paragraph in the primary RTF. -->
<xsl:template match="/" mode="insert.fo.block">
<xsl:param name="mark" select="'?'"/>
<xsl:apply-templates mode="insert.fo.block">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*" mode="insert.fo.block">
<xsl:param name="mark" select="'?'"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="insert.fo.block">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="fo:block" mode="insert.fo.block">
<xsl:param name="mark" select="'?'"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:if test="not(preceding::fo:block)">
<xsl:copy-of select="$mark"/>
</xsl:if>
<xsl:apply-templates mode="insert.fo.block">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.block">
<xsl:param name="mark" select="'?'"/>
<xsl:copy/>
</xsl:template>
<!-- ==================================================================== -->
<!-- insert.fo.text mode templates insert a particular RTF at the beginning
of the first text-node in the primary RTF. -->
<xsl:template match="/" mode="insert.fo.text">
<xsl:param name="mark" select="'?'"/>
<xsl:apply-templates mode="insert.fo.text">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*" mode="insert.fo.text">
<xsl:param name="mark" select="'?'"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="insert.fo.text">
<xsl:with-param name="mark" select="$mark"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.text">
<xsl:param name="mark" select="'?'"/>
<xsl:if test="not(preceding::text())">
<xsl:copy-of select="$mark"/>
</xsl:if>
<xsl:copy/>
</xsl:template>
<xsl:template match="processing-instruction()|comment()" mode="insert.fo.text">
<xsl:param name="mark" select="'?'"/>
<xsl:copy/>
</xsl:template>
<!-- ==================================================================== -->
</xsl:stylesheet>
|