[c873d807] | 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"
|
---|
| 4 | version='1.0'>
|
---|
| 5 |
|
---|
| 6 | <!-- ********************************************************************
|
---|
[b1a51ac1] | 7 | $Id: spaces.xsl 9647 2012-10-26 17:42:03Z bobstayton $
|
---|
[c873d807] | 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 | ******************************************************************** -->
|
---|
| 13 |
|
---|
[b1a51ac1] | 14 | <xsl:template match="text()[namespace-uri(..) = '' or
|
---|
| 15 | namespace-uri(..) = 'http://docbook.org/ns/docbook']">
|
---|
| 16 | <xsl:call-template name="space.2000.subst">
|
---|
| 17 | <xsl:with-param name="string" select="."/>
|
---|
| 18 | </xsl:call-template>
|
---|
[c873d807] | 19 | </xsl:template>
|
---|
| 20 |
|
---|
| 21 | <xsl:param name="space.enquad.width">0.5em</xsl:param> <!-- U+2000 -->
|
---|
| 22 | <xsl:param name="space.emquad.width">1em</xsl:param> <!-- U+2001 -->
|
---|
| 23 | <xsl:param name="space.enspace.width">0.5em</xsl:param> <!-- U+2002 -->
|
---|
| 24 | <xsl:param name="space.emspace.width">1em</xsl:param> <!-- U+2003 -->
|
---|
| 25 | <xsl:param name="space.3emspace.width">0.33em</xsl:param><!-- U+2004 -->
|
---|
| 26 | <xsl:param name="space.4emspace.width">0.25em</xsl:param><!-- U+2005 -->
|
---|
| 27 | <xsl:param name="space.6emspace.width">0.16em</xsl:param><!-- U+2006 -->
|
---|
| 28 | <xsl:param name="space.figspace.width"></xsl:param> <!-- U+2007 -->
|
---|
| 29 | <xsl:param name="space.punctspace.width"></xsl:param> <!-- U+2008 -->
|
---|
| 30 | <xsl:param name="space.thinspace.width">0.2em</xsl:param><!-- U+2009 -->
|
---|
| 31 | <xsl:param name="space.hairspace.width">0.1em</xsl:param><!-- U+200A -->
|
---|
| 32 |
|
---|
| 33 | <xsl:template name="space.2000.subst">
|
---|
| 34 | <xsl:param name="string"/>
|
---|
| 35 |
|
---|
| 36 | <xsl:choose>
|
---|
| 37 | <xsl:when test="contains($string, ' ') and $space.enquad.width != ''">
|
---|
| 38 | <xsl:call-template name="space.2001.subst">
|
---|
| 39 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 40 | </xsl:call-template>
|
---|
| 41 | <fo:leader leader-length="{$space.enquad.width}"/>
|
---|
| 42 | <xsl:call-template name="space.2000.subst">
|
---|
| 43 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 44 | </xsl:call-template>
|
---|
| 45 | </xsl:when>
|
---|
| 46 | <xsl:otherwise>
|
---|
| 47 | <xsl:call-template name="space.2001.subst">
|
---|
| 48 | <xsl:with-param name="string" select="$string"/>
|
---|
| 49 | </xsl:call-template>
|
---|
| 50 | </xsl:otherwise>
|
---|
| 51 | </xsl:choose>
|
---|
| 52 | </xsl:template>
|
---|
| 53 |
|
---|
| 54 | <xsl:template name="space.2001.subst">
|
---|
| 55 | <xsl:param name="string"/>
|
---|
| 56 |
|
---|
| 57 | <xsl:choose>
|
---|
| 58 | <xsl:when test="contains($string, ' ') and $space.emquad.width != ''">
|
---|
| 59 | <xsl:call-template name="space.2002.subst">
|
---|
| 60 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 61 | </xsl:call-template>
|
---|
| 62 | <fo:leader leader-length="{$space.emquad.width}"/>
|
---|
| 63 | <xsl:call-template name="space.2001.subst">
|
---|
| 64 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 65 | </xsl:call-template>
|
---|
| 66 | </xsl:when>
|
---|
| 67 | <xsl:otherwise>
|
---|
| 68 | <xsl:call-template name="space.2002.subst">
|
---|
| 69 | <xsl:with-param name="string" select="$string"/>
|
---|
| 70 | </xsl:call-template>
|
---|
| 71 | </xsl:otherwise>
|
---|
| 72 | </xsl:choose>
|
---|
| 73 | </xsl:template>
|
---|
| 74 |
|
---|
| 75 | <xsl:template name="space.2002.subst">
|
---|
| 76 | <xsl:param name="string"/>
|
---|
| 77 |
|
---|
| 78 | <xsl:choose>
|
---|
| 79 | <xsl:when test="contains($string, ' ') and $space.enspace.width != ''">
|
---|
| 80 | <xsl:call-template name="space.2003.subst">
|
---|
| 81 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 82 | </xsl:call-template>
|
---|
| 83 | <fo:leader leader-length="{$space.enspace.width}"/>
|
---|
| 84 | <xsl:call-template name="space.2002.subst">
|
---|
| 85 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 86 | </xsl:call-template>
|
---|
| 87 | </xsl:when>
|
---|
| 88 | <xsl:otherwise>
|
---|
| 89 | <xsl:call-template name="space.2003.subst">
|
---|
| 90 | <xsl:with-param name="string" select="$string"/>
|
---|
| 91 | </xsl:call-template>
|
---|
| 92 | </xsl:otherwise>
|
---|
| 93 | </xsl:choose>
|
---|
| 94 | </xsl:template>
|
---|
| 95 |
|
---|
| 96 | <xsl:template name="space.2003.subst">
|
---|
| 97 | <xsl:param name="string"/>
|
---|
| 98 |
|
---|
| 99 | <xsl:choose>
|
---|
| 100 | <xsl:when test="contains($string, ' ') and $space.emspace.width != ''">
|
---|
| 101 | <xsl:call-template name="space.2004.subst">
|
---|
| 102 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 103 | </xsl:call-template>
|
---|
| 104 | <fo:leader leader-length="{$space.emspace.width}"/>
|
---|
| 105 | <xsl:call-template name="space.2003.subst">
|
---|
| 106 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 107 | </xsl:call-template>
|
---|
| 108 | </xsl:when>
|
---|
| 109 | <xsl:otherwise>
|
---|
| 110 | <xsl:call-template name="space.2004.subst">
|
---|
| 111 | <xsl:with-param name="string" select="$string"/>
|
---|
| 112 | </xsl:call-template>
|
---|
| 113 | </xsl:otherwise>
|
---|
| 114 | </xsl:choose>
|
---|
| 115 | </xsl:template>
|
---|
| 116 |
|
---|
| 117 | <xsl:template name="space.2004.subst">
|
---|
| 118 | <xsl:param name="string"/>
|
---|
| 119 |
|
---|
| 120 | <xsl:choose>
|
---|
| 121 | <xsl:when test="contains($string, ' ') and $space.3emspace.width != ''">
|
---|
| 122 | <xsl:call-template name="space.2005.subst">
|
---|
| 123 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 124 | </xsl:call-template>
|
---|
| 125 | <fo:leader leader-length="{$space.3emspace.width}"/>
|
---|
| 126 | <xsl:call-template name="space.2004.subst">
|
---|
| 127 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 128 | </xsl:call-template>
|
---|
| 129 | </xsl:when>
|
---|
| 130 | <xsl:otherwise>
|
---|
| 131 | <xsl:call-template name="space.2005.subst">
|
---|
| 132 | <xsl:with-param name="string" select="$string"/>
|
---|
| 133 | </xsl:call-template>
|
---|
| 134 | </xsl:otherwise>
|
---|
| 135 | </xsl:choose>
|
---|
| 136 | </xsl:template>
|
---|
| 137 |
|
---|
| 138 | <xsl:template name="space.2005.subst">
|
---|
| 139 | <xsl:param name="string"/>
|
---|
| 140 |
|
---|
| 141 | <xsl:choose>
|
---|
| 142 | <xsl:when test="contains($string, ' ') and $space.4emspace.width != ''">
|
---|
| 143 | <xsl:call-template name="space.2006.subst">
|
---|
| 144 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 145 | </xsl:call-template>
|
---|
| 146 | <fo:leader leader-length="{$space.4emspace.width}"/>
|
---|
| 147 | <xsl:call-template name="space.2005.subst">
|
---|
| 148 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 149 | </xsl:call-template>
|
---|
| 150 | </xsl:when>
|
---|
| 151 | <xsl:otherwise>
|
---|
| 152 | <xsl:call-template name="space.2006.subst">
|
---|
| 153 | <xsl:with-param name="string" select="$string"/>
|
---|
| 154 | </xsl:call-template>
|
---|
| 155 | </xsl:otherwise>
|
---|
| 156 | </xsl:choose>
|
---|
| 157 | </xsl:template>
|
---|
| 158 |
|
---|
| 159 | <xsl:template name="space.2006.subst">
|
---|
| 160 | <xsl:param name="string"/>
|
---|
| 161 |
|
---|
| 162 | <xsl:choose>
|
---|
| 163 | <xsl:when test="contains($string, ' ') and $space.6emspace.width != ''">
|
---|
| 164 | <xsl:call-template name="space.2007.subst">
|
---|
| 165 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 166 | </xsl:call-template>
|
---|
| 167 | <fo:leader leader-length="{$space.6emspace.width}"/>
|
---|
| 168 | <xsl:call-template name="space.2006.subst">
|
---|
| 169 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 170 | </xsl:call-template>
|
---|
| 171 | </xsl:when>
|
---|
| 172 | <xsl:otherwise>
|
---|
| 173 | <xsl:call-template name="space.2007.subst">
|
---|
| 174 | <xsl:with-param name="string" select="$string"/>
|
---|
| 175 | </xsl:call-template>
|
---|
| 176 | </xsl:otherwise>
|
---|
| 177 | </xsl:choose>
|
---|
| 178 | </xsl:template>
|
---|
| 179 |
|
---|
| 180 | <xsl:template name="space.2007.subst">
|
---|
| 181 | <xsl:param name="string"/>
|
---|
| 182 |
|
---|
| 183 | <xsl:choose>
|
---|
| 184 | <xsl:when test="contains($string, ' ') and $space.figspace.width != ''">
|
---|
| 185 | <xsl:call-template name="space.2008.subst">
|
---|
| 186 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 187 | </xsl:call-template>
|
---|
| 188 | <fo:leader leader-length="{$space.figspace.width}"/>
|
---|
| 189 | <xsl:call-template name="space.2007.subst">
|
---|
| 190 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 191 | </xsl:call-template>
|
---|
| 192 | </xsl:when>
|
---|
| 193 | <xsl:otherwise>
|
---|
| 194 | <xsl:call-template name="space.2008.subst">
|
---|
| 195 | <xsl:with-param name="string" select="$string"/>
|
---|
| 196 | </xsl:call-template>
|
---|
| 197 | </xsl:otherwise>
|
---|
| 198 | </xsl:choose>
|
---|
| 199 | </xsl:template>
|
---|
| 200 |
|
---|
| 201 | <xsl:template name="space.2008.subst">
|
---|
| 202 | <xsl:param name="string"/>
|
---|
| 203 |
|
---|
| 204 | <xsl:choose>
|
---|
| 205 | <xsl:when test="contains($string, ' ') and $space.punctspace.width != ''">
|
---|
| 206 | <xsl:call-template name="space.2009.subst">
|
---|
| 207 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 208 | </xsl:call-template>
|
---|
| 209 | <fo:leader leader-length="{$space.punctspace.width}"/>
|
---|
| 210 | <xsl:call-template name="space.2008.subst">
|
---|
| 211 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 212 | </xsl:call-template>
|
---|
| 213 | </xsl:when>
|
---|
| 214 | <xsl:otherwise>
|
---|
| 215 | <xsl:call-template name="space.2009.subst">
|
---|
| 216 | <xsl:with-param name="string" select="$string"/>
|
---|
| 217 | </xsl:call-template>
|
---|
| 218 | </xsl:otherwise>
|
---|
| 219 | </xsl:choose>
|
---|
| 220 | </xsl:template>
|
---|
| 221 |
|
---|
| 222 | <xsl:template name="space.2009.subst">
|
---|
| 223 | <xsl:param name="string"/>
|
---|
| 224 |
|
---|
| 225 | <xsl:choose>
|
---|
| 226 | <xsl:when test="contains($string, ' ') and $space.thinspace.width != ''">
|
---|
| 227 | <xsl:call-template name="space.200A.subst">
|
---|
| 228 | <xsl:with-param name="string" select="substring-before($string, ' ')"/>
|
---|
| 229 | </xsl:call-template>
|
---|
| 230 | <fo:leader leader-length="{$space.thinspace.width}"/>
|
---|
| 231 | <xsl:call-template name="space.2009.subst">
|
---|
| 232 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 233 | </xsl:call-template>
|
---|
| 234 | </xsl:when>
|
---|
| 235 | <xsl:otherwise>
|
---|
| 236 | <xsl:call-template name="space.200A.subst">
|
---|
| 237 | <xsl:with-param name="string" select="$string"/>
|
---|
| 238 | </xsl:call-template>
|
---|
| 239 | </xsl:otherwise>
|
---|
| 240 | </xsl:choose>
|
---|
| 241 | </xsl:template>
|
---|
| 242 |
|
---|
| 243 | <xsl:template name="space.200A.subst">
|
---|
| 244 | <xsl:param name="string"/>
|
---|
| 245 |
|
---|
| 246 | <xsl:choose>
|
---|
| 247 | <xsl:when test="contains($string, ' ') and $space.hairspace.width != ''">
|
---|
| 248 | <xsl:value-of select="substring-before($string, ' ')"/>
|
---|
| 249 | <fo:leader leader-length="{$space.hairspace.width}"/>
|
---|
| 250 | <xsl:call-template name="space.200A.subst">
|
---|
| 251 | <xsl:with-param name="string" select="substring-after($string, ' ')"/>
|
---|
| 252 | </xsl:call-template>
|
---|
| 253 | </xsl:when>
|
---|
| 254 | <xsl:otherwise>
|
---|
| 255 | <xsl:value-of select="$string"/>
|
---|
| 256 | </xsl:otherwise>
|
---|
| 257 | </xsl:choose>
|
---|
| 258 | </xsl:template>
|
---|
| 259 |
|
---|
| 260 | </xsl:stylesheet>
|
---|
| 261 |
|
---|