| 1 |
<?xml version='1.0'?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
xmlns:d="http://docbook.org/ns/docbook" |
| 4 |
xmlns:fo="http://www.w3.org/1999/XSL/Format" |
| 5 |
xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim" |
| 6 |
xmlns:xverb="com.nwalsh.xalan.Verbatim" |
| 7 |
xmlns:lxslt="http://xml.apache.org/xslt" |
| 8 |
exclude-result-prefixes="sverb xverb lxslt d" |
| 9 |
version='1.0'> |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
<lxslt:component prefix="xverb" |
| 20 |
functions="insertCallouts"/> |
| 21 |
|
| 22 |
<xsl:template match="d:programlistingco|d:screenco"> |
| 23 |
<xsl:variable name="verbatim" select="d:programlisting|d:screen"/> |
| 24 |
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/> |
| 25 |
|
| 26 |
<xsl:choose> |
| 27 |
<xsl:when test="$use.extensions != '0' |
| 28 |
and $callouts.extension != '0'"> |
| 29 |
<xsl:variable name="rtf"> |
| 30 |
<xsl:apply-templates select="$verbatim"> |
| 31 |
<xsl:with-param name="suppress-numbers" select="'1'"/> |
| 32 |
</xsl:apply-templates> |
| 33 |
</xsl:variable> |
| 34 |
|
| 35 |
<xsl:variable name="rtf-with-callouts"> |
| 36 |
<xsl:choose> |
| 37 |
<xsl:when test="contains($vendor, 'SAXON ')"> |
| 38 |
<xsl:copy-of select="sverb:insertCallouts(d:areaspec,$rtf)"/> |
| 39 |
</xsl:when> |
| 40 |
<xsl:when test="contains($vendor, 'Apache Software Foundation')"> |
| 41 |
<xsl:copy-of select="xverb:insertCallouts(d:areaspec,$rtf)"/> |
| 42 |
</xsl:when> |
| 43 |
<xsl:otherwise> |
| 44 |
<xsl:message terminate="yes"> |
| 45 |
<xsl:text>Don't know how to do callouts with </xsl:text> |
| 46 |
<xsl:value-of select="$vendor"/> |
| 47 |
</xsl:message> |
| 48 |
</xsl:otherwise> |
| 49 |
</xsl:choose> |
| 50 |
</xsl:variable> |
| 51 |
|
| 52 |
<xsl:choose> |
| 53 |
<xsl:when test="$verbatim/@linenumbering = 'numbered' |
| 54 |
and $linenumbering.extension != '0'"> |
| 55 |
<xsl:call-template name="number.rtf.lines"> |
| 56 |
<xsl:with-param name="rtf" select="$rtf-with-callouts"/> |
| 57 |
<xsl:with-param name="pi.context" |
| 58 |
select="d:programlisting|d:screen"/> |
| 59 |
</xsl:call-template> |
| 60 |
<xsl:apply-templates select="d:calloutlist"/> |
| 61 |
</xsl:when> |
| 62 |
<xsl:otherwise> |
| 63 |
<xsl:copy-of select="$rtf-with-callouts"/> |
| 64 |
<xsl:apply-templates select="d:calloutlist"/> |
| 65 |
</xsl:otherwise> |
| 66 |
</xsl:choose> |
| 67 |
</xsl:when> |
| 68 |
<xsl:otherwise> |
| 69 |
<xsl:apply-templates/> |
| 70 |
</xsl:otherwise> |
| 71 |
</xsl:choose> |
| 72 |
</xsl:template> |
| 73 |
|
| 74 |
<xsl:template match="d:areaspec|d:areaset|d:area"> |
| 75 |
</xsl:template> |
| 76 |
|
| 77 |
<xsl:template match="d:areaset" mode="conumber"> |
| 78 |
<xsl:number count="d:area|d:areaset" format="1"/> |
| 79 |
</xsl:template> |
| 80 |
|
| 81 |
<xsl:template match="d:area" mode="conumber"> |
| 82 |
<xsl:number count="d:area|d:areaset" format="1"/> |
| 83 |
</xsl:template> |
| 84 |
|
| 85 |
<xsl:template match="d:co"> |
| 86 |
<xsl:param name="coref"/> |
| 87 |
|
| 88 |
<xsl:variable name="linkend"> |
| 89 |
<xsl:choose> |
| 90 |
|
| 91 |
<xsl:when test="contains(normalize-space(@linkends), ' ')"> |
| 92 |
<xsl:value-of select="substring-before(normalize-space(@linkends), ' ')"/> |
| 93 |
</xsl:when> |
| 94 |
<xsl:when test="string-length(normalize-space(@linkends)) != 0"> |
| 95 |
<xsl:value-of select="normalize-space(@linkends)"/> |
| 96 |
</xsl:when> |
| 97 |
<xsl:otherwise> |
| 98 |
</xsl:otherwise> |
| 99 |
</xsl:choose> |
| 100 |
</xsl:variable> |
| 101 |
|
| 102 |
<xsl:choose> |
| 103 |
<xsl:when test="string-length($linkend) != 0"> |
| 104 |
<fo:basic-link internal-destination="{$linkend}"> |
| 105 |
<xsl:choose> |
| 106 |
<xsl:when test="$coref"> |
| 107 |
<xsl:call-template name="anchor"> |
| 108 |
<xsl:with-param name="node" select="$coref"/> |
| 109 |
<xsl:with-param name="conditional" select="0"/> |
| 110 |
</xsl:call-template> |
| 111 |
</xsl:when> |
| 112 |
<xsl:otherwise> |
| 113 |
<xsl:call-template name="anchor"> |
| 114 |
<xsl:with-param name="conditional" select="0"/> |
| 115 |
</xsl:call-template> |
| 116 |
</xsl:otherwise> |
| 117 |
</xsl:choose> |
| 118 |
<xsl:apply-templates select="." mode="callout-bug"/> |
| 119 |
</fo:basic-link> |
| 120 |
</xsl:when> |
| 121 |
<xsl:otherwise> |
| 122 |
<fo:inline> |
| 123 |
<xsl:choose> |
| 124 |
<xsl:when test="$coref"> |
| 125 |
<xsl:call-template name="anchor"> |
| 126 |
<xsl:with-param name="node" select="$coref"/> |
| 127 |
<xsl:with-param name="conditional" select="0"/> |
| 128 |
</xsl:call-template> |
| 129 |
</xsl:when> |
| 130 |
<xsl:otherwise> |
| 131 |
<xsl:call-template name="anchor"> |
| 132 |
<xsl:with-param name="conditional" select="0"/> |
| 133 |
</xsl:call-template> |
| 134 |
</xsl:otherwise> |
| 135 |
</xsl:choose> |
| 136 |
<xsl:apply-templates select="." mode="callout-bug"/> |
| 137 |
</fo:inline> |
| 138 |
</xsl:otherwise> |
| 139 |
</xsl:choose> |
| 140 |
</xsl:template> |
| 141 |
|
| 142 |
<xsl:template match="d:coref"> |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
<xsl:variable name="co" select="key('id', @linkend)"/> |
| 147 |
<xsl:choose> |
| 148 |
<xsl:when test="not($co)"> |
| 149 |
<xsl:message> |
| 150 |
<xsl:text>Error: coref link is broken: </xsl:text> |
| 151 |
<xsl:value-of select="@linkend"/> |
| 152 |
</xsl:message> |
| 153 |
</xsl:when> |
| 154 |
<xsl:when test="local-name($co) != 'co'"> |
| 155 |
<xsl:message> |
| 156 |
<xsl:text>Error: coref doesn't point to a co: </xsl:text> |
| 157 |
<xsl:value-of select="@linkend"/> |
| 158 |
</xsl:message> |
| 159 |
</xsl:when> |
| 160 |
<xsl:otherwise> |
| 161 |
|
| 162 |
<xsl:apply-templates select="$co"> |
| 163 |
<xsl:with-param name="coref" select="."/> |
| 164 |
</xsl:apply-templates> |
| 165 |
</xsl:otherwise> |
| 166 |
</xsl:choose> |
| 167 |
</xsl:template> |
| 168 |
|
| 169 |
<xsl:template match="d:co" mode="callout-bug"> |
| 170 |
<xsl:call-template name="callout-bug"> |
| 171 |
<xsl:with-param name="conum"> |
| 172 |
<xsl:number count="d:co" |
| 173 |
level="any" |
| 174 |
from="d:programlisting|d:screen|d:literallayout|d:synopsis" |
| 175 |
format="1"/> |
| 176 |
</xsl:with-param> |
| 177 |
</xsl:call-template> |
| 178 |
</xsl:template> |
| 179 |
|
| 180 |
<xsl:template name="callout-bug"> |
| 181 |
<xsl:param name="conum" select='1'/> |
| 182 |
|
| 183 |
<xsl:choose> |
| 184 |
|
| 185 |
<xsl:when test="$callout.graphics != '0' |
| 186 |
and $conum <= $callout.graphics.number.limit"> |
| 187 |
<xsl:variable name="filename" |
| 188 |
select="concat($callout.graphics.path, $conum, |
| 189 |
$callout.graphics.extension)"/> |
| 190 |
|
| 191 |
<fo:external-graphic content-width="{$callout.icon.size}" |
| 192 |
width="{$callout.icon.size}"> |
| 193 |
<xsl:attribute name="src"> |
| 194 |
<xsl:choose> |
| 195 |
<xsl:when test="$fop.extensions != 0 |
| 196 |
or $arbortext.extensions != 0"> |
| 197 |
<xsl:value-of select="$filename"/> |
| 198 |
</xsl:when> |
| 199 |
<xsl:otherwise> |
| 200 |
<xsl:text>url(</xsl:text> |
| 201 |
<xsl:value-of select="$filename"/> |
| 202 |
<xsl:text>)</xsl:text> |
| 203 |
</xsl:otherwise> |
| 204 |
</xsl:choose> |
| 205 |
</xsl:attribute> |
| 206 |
</fo:external-graphic> |
| 207 |
</xsl:when> |
| 208 |
|
| 209 |
<xsl:when test="$callout.unicode != 0 |
| 210 |
and $conum <= $callout.unicode.number.limit"> |
| 211 |
<xsl:variable name="comarkup"> |
| 212 |
<xsl:choose> |
| 213 |
<xsl:when test="$callout.unicode.start.character = 10102"> |
| 214 |
<xsl:choose> |
| 215 |
<xsl:when test="$conum = 1">❶</xsl:when> |
| 216 |
<xsl:when test="$conum = 2">❷</xsl:when> |
| 217 |
<xsl:when test="$conum = 3">❸</xsl:when> |
| 218 |
<xsl:when test="$conum = 4">❹</xsl:when> |
| 219 |
<xsl:when test="$conum = 5">❺</xsl:when> |
| 220 |
<xsl:when test="$conum = 6">❻</xsl:when> |
| 221 |
<xsl:when test="$conum = 7">❼</xsl:when> |
| 222 |
<xsl:when test="$conum = 8">❽</xsl:when> |
| 223 |
<xsl:when test="$conum = 9">❾</xsl:when> |
| 224 |
<xsl:when test="$conum = 10">❿</xsl:when> |
| 225 |
<xsl:when test="$conum = 11">⓫</xsl:when> |
| 226 |
<xsl:when test="$conum = 12">⓬</xsl:when> |
| 227 |
<xsl:when test="$conum = 13">⓭</xsl:when> |
| 228 |
<xsl:when test="$conum = 14">⓮</xsl:when> |
| 229 |
<xsl:when test="$conum = 15">⓯</xsl:when> |
| 230 |
<xsl:when test="$conum = 16">⓰</xsl:when> |
| 231 |
<xsl:when test="$conum = 17">⓱</xsl:when> |
| 232 |
<xsl:when test="$conum = 18">⓲</xsl:when> |
| 233 |
<xsl:when test="$conum = 19">⓳</xsl:when> |
| 234 |
<xsl:when test="$conum = 20">⓴</xsl:when> |
| 235 |
</xsl:choose> |
| 236 |
</xsl:when> |
| 237 |
<xsl:when test="$callout.unicode.start.character = 9312"> |
| 238 |
<xsl:choose> |
| 239 |
<xsl:when test="$conum = 1">①</xsl:when> |
| 240 |
<xsl:when test="$conum = 2">②</xsl:when> |
| 241 |
<xsl:when test="$conum = 3">③</xsl:when> |
| 242 |
<xsl:when test="$conum = 4">④</xsl:when> |
| 243 |
<xsl:when test="$conum = 5">⑤</xsl:when> |
| 244 |
<xsl:when test="$conum = 6">⑥</xsl:when> |
| 245 |
<xsl:when test="$conum = 7">⑦</xsl:when> |
| 246 |
<xsl:when test="$conum = 8">⑧</xsl:when> |
| 247 |
<xsl:when test="$conum = 9">⑨</xsl:when> |
| 248 |
<xsl:when test="$conum = 10">⑩</xsl:when> |
| 249 |
<xsl:when test="$conum = 11">⑪</xsl:when> |
| 250 |
<xsl:when test="$conum = 12">⑫</xsl:when> |
| 251 |
<xsl:when test="$conum = 13">⑬</xsl:when> |
| 252 |
<xsl:when test="$conum = 14">⑭</xsl:when> |
| 253 |
<xsl:when test="$conum = 15">⑮</xsl:when> |
| 254 |
<xsl:when test="$conum = 16">⑯</xsl:when> |
| 255 |
<xsl:when test="$conum = 17">⑰</xsl:when> |
| 256 |
<xsl:when test="$conum = 18">⑱</xsl:when> |
| 257 |
<xsl:when test="$conum = 19">⑲</xsl:when> |
| 258 |
<xsl:when test="$conum = 20">⑳</xsl:when> |
| 259 |
</xsl:choose> |
| 260 |
</xsl:when> |
| 261 |
<xsl:otherwise> |
| 262 |
<xsl:message> |
| 263 |
<xsl:text>Don't know how to generate Unicode callouts </xsl:text> |
| 264 |
<xsl:text>when $callout.unicode.start.character is </xsl:text> |
| 265 |
<xsl:value-of select="$callout.unicode.start.character"/> |
| 266 |
</xsl:message> |
| 267 |
<fo:inline background-color="#404040" |
| 268 |
color="white" |
| 269 |
padding-top="0.1em" |
| 270 |
padding-bottom="0.1em" |
| 271 |
padding-start="0.2em" |
| 272 |
padding-end="0.2em" |
| 273 |
baseline-shift="0.1em" |
| 274 |
font-family="{$body.fontset}" |
| 275 |
font-weight="bold" |
| 276 |
font-size="75%"> |
| 277 |
<xsl:value-of select="$conum"/> |
| 278 |
</fo:inline> |
| 279 |
</xsl:otherwise> |
| 280 |
</xsl:choose> |
| 281 |
</xsl:variable> |
| 282 |
|
| 283 |
<xsl:choose> |
| 284 |
<xsl:when test="$callout.unicode.font != ''"> |
| 285 |
<fo:inline font-family="{$callout.unicode.font}"> |
| 286 |
<xsl:copy-of select="$comarkup"/> |
| 287 |
</fo:inline> |
| 288 |
</xsl:when> |
| 289 |
<xsl:otherwise> |
| 290 |
<xsl:copy-of select="$comarkup"/> |
| 291 |
</xsl:otherwise> |
| 292 |
</xsl:choose> |
| 293 |
</xsl:when> |
| 294 |
|
| 295 |
|
| 296 |
<xsl:otherwise> |
| 297 |
<fo:inline background-color="#404040" |
| 298 |
color="white" |
| 299 |
padding-top="0.1em" |
| 300 |
padding-bottom="0.1em" |
| 301 |
padding-start="0.2em" |
| 302 |
padding-end="0.2em" |
| 303 |
baseline-shift="0.1em" |
| 304 |
font-family="{$body.fontset}" |
| 305 |
font-weight="bold" |
| 306 |
font-size="75%"> |
| 307 |
<xsl:value-of select="$conum"/> |
| 308 |
</fo:inline> |
| 309 |
</xsl:otherwise> |
| 310 |
</xsl:choose> |
| 311 |
</xsl:template> |
| 312 |
|
| 313 |
</xsl:stylesheet> |