1 <?xml version='1.0' encoding="utf-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
6 <!-- ********************************************************************
7 $Id: spaces.xsl 8121 2008-09-13 17:21:11Z mzjn $
8 ********************************************************************
9 XSL-FO specification treats all space characters like ordinary spaces.
10 We need to map them to fo:leader with different widths in order to
11 simulate desired behaviour.
12 ******************************************************************** -->
14 <xsl:template match="text()[namespace-uri(..) = '' or
15 namespace-uri(..) = 'http://docbook.org/ns/docbook']">
17 <xsl:when test="$passivetex.extensions != 0">
18 <xsl:call-template name="passivetex.dash.subst">
19 <xsl:with-param name="string">
20 <xsl:call-template name="space.2000.subst">
21 <xsl:with-param name="string" select="."/>
27 <xsl:call-template name="space.2000.subst">
28 <xsl:with-param name="string" select="."/>
34 <xsl:param name="space.enquad.width">0.5em</xsl:param> <!-- U+2000 -->
35 <xsl:param name="space.emquad.width">1em</xsl:param> <!-- U+2001 -->
36 <xsl:param name="space.enspace.width">0.5em</xsl:param> <!-- U+2002 -->
37 <xsl:param name="space.emspace.width">1em</xsl:param> <!-- U+2003 -->
38 <xsl:param name="space.3emspace.width">0.33em</xsl:param><!-- U+2004 -->
39 <xsl:param name="space.4emspace.width">0.25em</xsl:param><!-- U+2005 -->
40 <xsl:param name="space.6emspace.width">0.16em</xsl:param><!-- U+2006 -->
41 <xsl:param name="space.figspace.width"></xsl:param> <!-- U+2007 -->
42 <xsl:param name="space.punctspace.width"></xsl:param> <!-- U+2008 -->
43 <xsl:param name="space.thinspace.width">0.2em</xsl:param><!-- U+2009 -->
44 <xsl:param name="space.hairspace.width">0.1em</xsl:param><!-- U+200A -->
46 <xsl:template name="space.2000.subst">
47 <xsl:param name="string"/>
50 <xsl:when test="contains($string, ' ') and $space.enquad.width != ''">
51 <xsl:call-template name="space.2001.subst">
52 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
54 <fo:leader leader-length="{$space.enquad.width}"/>
55 <xsl:call-template name="space.2000.subst">
56 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
60 <xsl:call-template name="space.2001.subst">
61 <xsl:with-param name="string" select="$string"/>
67 <xsl:template name="space.2001.subst">
68 <xsl:param name="string"/>
71 <xsl:when test="contains($string, ' ') and $space.emquad.width != ''">
72 <xsl:call-template name="space.2002.subst">
73 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
75 <fo:leader leader-length="{$space.emquad.width}"/>
76 <xsl:call-template name="space.2001.subst">
77 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
81 <xsl:call-template name="space.2002.subst">
82 <xsl:with-param name="string" select="$string"/>
88 <xsl:template name="space.2002.subst">
89 <xsl:param name="string"/>
92 <xsl:when test="contains($string, ' ') and $space.enspace.width != ''">
93 <xsl:call-template name="space.2003.subst">
94 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
96 <fo:leader leader-length="{$space.enspace.width}"/>
97 <xsl:call-template name="space.2002.subst">
98 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
102 <xsl:call-template name="space.2003.subst">
103 <xsl:with-param name="string" select="$string"/>
109 <xsl:template name="space.2003.subst">
110 <xsl:param name="string"/>
113 <xsl:when test="contains($string, ' ') and $space.emspace.width != ''">
114 <xsl:call-template name="space.2004.subst">
115 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
117 <fo:leader leader-length="{$space.emspace.width}"/>
118 <xsl:call-template name="space.2003.subst">
119 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
123 <xsl:call-template name="space.2004.subst">
124 <xsl:with-param name="string" select="$string"/>
130 <xsl:template name="space.2004.subst">
131 <xsl:param name="string"/>
134 <xsl:when test="contains($string, ' ') and $space.3emspace.width != ''">
135 <xsl:call-template name="space.2005.subst">
136 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
138 <fo:leader leader-length="{$space.3emspace.width}"/>
139 <xsl:call-template name="space.2004.subst">
140 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
144 <xsl:call-template name="space.2005.subst">
145 <xsl:with-param name="string" select="$string"/>
151 <xsl:template name="space.2005.subst">
152 <xsl:param name="string"/>
155 <xsl:when test="contains($string, ' ') and $space.4emspace.width != ''">
156 <xsl:call-template name="space.2006.subst">
157 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
159 <fo:leader leader-length="{$space.4emspace.width}"/>
160 <xsl:call-template name="space.2005.subst">
161 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
165 <xsl:call-template name="space.2006.subst">
166 <xsl:with-param name="string" select="$string"/>
172 <xsl:template name="space.2006.subst">
173 <xsl:param name="string"/>
176 <xsl:when test="contains($string, ' ') and $space.6emspace.width != ''">
177 <xsl:call-template name="space.2007.subst">
178 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
180 <fo:leader leader-length="{$space.6emspace.width}"/>
181 <xsl:call-template name="space.2006.subst">
182 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
186 <xsl:call-template name="space.2007.subst">
187 <xsl:with-param name="string" select="$string"/>
193 <xsl:template name="space.2007.subst">
194 <xsl:param name="string"/>
197 <xsl:when test="contains($string, ' ') and $space.figspace.width != ''">
198 <xsl:call-template name="space.2008.subst">
199 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
201 <fo:leader leader-length="{$space.figspace.width}"/>
202 <xsl:call-template name="space.2007.subst">
203 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
207 <xsl:call-template name="space.2008.subst">
208 <xsl:with-param name="string" select="$string"/>
214 <xsl:template name="space.2008.subst">
215 <xsl:param name="string"/>
218 <xsl:when test="contains($string, ' ') and $space.punctspace.width != ''">
219 <xsl:call-template name="space.2009.subst">
220 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
222 <fo:leader leader-length="{$space.punctspace.width}"/>
223 <xsl:call-template name="space.2008.subst">
224 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
228 <xsl:call-template name="space.2009.subst">
229 <xsl:with-param name="string" select="$string"/>
235 <xsl:template name="space.2009.subst">
236 <xsl:param name="string"/>
239 <xsl:when test="contains($string, ' ') and $space.thinspace.width != ''">
240 <xsl:call-template name="space.200A.subst">
241 <xsl:with-param name="string" select="substring-before($string, ' ')"/>
243 <fo:leader leader-length="{$space.thinspace.width}"/>
244 <xsl:call-template name="space.2009.subst">
245 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
249 <xsl:call-template name="space.200A.subst">
250 <xsl:with-param name="string" select="$string"/>
256 <xsl:template name="space.200A.subst">
257 <xsl:param name="string"/>
260 <xsl:when test="contains($string, ' ') and $space.hairspace.width != ''">
261 <xsl:value-of select="substring-before($string, ' ')"/>
262 <fo:leader leader-length="{$space.hairspace.width}"/>
263 <xsl:call-template name="space.200A.subst">
264 <xsl:with-param name="string" select="substring-after($string, ' ')"/>
268 <xsl:value-of select="$string"/>