1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:fo="http://www.w3.org/1999/XSL/Format" 4 xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim" 5 xmlns:xverb="com.nwalsh.xalan.Verbatim" 6 xmlns:lxslt="http://xml.apache.org/xslt" 7 exclude-result-prefixes="sverb xverb lxslt" 8 version='1.0'> 9 10<!-- ******************************************************************** 11 $Id$ 12 ******************************************************************** 13 14 This file is part of the XSL DocBook Stylesheet distribution. 15 See /README or http://nwalsh.com/docbook/xsl/ for copyright 16 and other information. 17 18 ******************************************************************** --> 19 20<lxslt:component prefix="xverb" 21 functions="insertCallouts"/> 22 23<xsl:template match="programlistingco|screenco"> 24 <xsl:variable name="verbatim" select="programlisting|screen"/> 25 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> 26 27 <xsl:choose> 28 <xsl:when test="$use.extensions != '0' 29 and $callouts.extension != '0'"> 30 <xsl:variable name="rtf"> 31 <xsl:apply-templates select="$verbatim"> 32 <xsl:with-param name="suppress-numbers" select="'1'"/> 33 </xsl:apply-templates> 34 </xsl:variable> 35 36 <xsl:variable name="rtf-with-callouts"> 37 <xsl:choose> 38 <xsl:when test="contains($vendor, 'SAXON ')"> 39 <xsl:copy-of select="sverb:insertCallouts(areaspec,$rtf)"/> 40 </xsl:when> 41 <xsl:when test="contains($vendor, 'Apache Software Foundation')"> 42 <xsl:copy-of select="xverb:insertCallouts(areaspec,$rtf)"/> 43 </xsl:when> 44 <xsl:otherwise> 45 <xsl:message terminate="yes"> 46 <xsl:text>Don't know how to do callouts with </xsl:text> 47 <xsl:value-of select="$vendor"/> 48 </xsl:message> 49 </xsl:otherwise> 50 </xsl:choose> 51 </xsl:variable> 52 53 <xsl:choose> 54 <xsl:when test="$verbatim/@linenumbering = 'numbered' 55 and $linenumbering.extension != '0'"> 56 <xsl:call-template name="number.rtf.lines"> 57 <xsl:with-param name="rtf" select="$rtf-with-callouts"/> 58 <xsl:with-param name="pi.context" 59 select="programlisting|screen"/> 60 </xsl:call-template> 61 <xsl:apply-templates select="calloutlist"/> 62 </xsl:when> 63 <xsl:otherwise> 64 <xsl:copy-of select="$rtf-with-callouts"/> 65 <xsl:apply-templates select="calloutlist"/> 66 </xsl:otherwise> 67 </xsl:choose> 68 </xsl:when> 69 <xsl:otherwise> 70 <xsl:apply-templates/> 71 </xsl:otherwise> 72 </xsl:choose> 73</xsl:template> 74 75<xsl:template match="areaspec|areaset|area"> 76</xsl:template> 77 78<xsl:template match="areaset" mode="conumber"> 79 <xsl:number count="area|areaset" format="1"/> 80</xsl:template> 81 82<xsl:template match="area" mode="conumber"> 83 <xsl:number count="area|areaset" format="1"/> 84</xsl:template> 85 86<xsl:template match="co"> 87 <fo:inline id="{@id}"> 88 <xsl:apply-templates select="." mode="callout-bug"/> 89 </fo:inline> 90</xsl:template> 91 92<xsl:template match="co" mode="callout-bug"> 93 <xsl:call-template name="callout-bug"> 94 <xsl:with-param name="conum"> 95 <xsl:number count="co" format="1"/> 96 </xsl:with-param> 97 </xsl:call-template> 98</xsl:template> 99 100<xsl:template name="callout-bug"> 101 <xsl:param name="conum" select='1'/> 102 103 <xsl:choose> 104 <!-- Draw callouts as images --> 105 <xsl:when test="$callout.graphics != '0' 106 and $conum <= $callout.graphics.number.limit"> 107 <fo:external-graphic 108 src="{$callout.graphics.path}{$conum}{$callout.graphics.extension}"/> 109 </xsl:when> 110 111 <xsl:when test="$callout.unicode != 0 112 and $conum <= $callout.unicode.number.limit"> 113 <xsl:choose> 114 <xsl:when test="$callout.unicode.start.character = 10102"> 115 <xsl:choose> 116 <xsl:when test="$conum = 1">❶</xsl:when> 117 <xsl:when test="$conum = 2">❷</xsl:when> 118 <xsl:when test="$conum = 3">❸</xsl:when> 119 <xsl:when test="$conum = 4">❹</xsl:when> 120 <xsl:when test="$conum = 5">❺</xsl:when> 121 <xsl:when test="$conum = 6">❻</xsl:when> 122 <xsl:when test="$conum = 7">❼</xsl:when> 123 <xsl:when test="$conum = 8">❽</xsl:when> 124 <xsl:when test="$conum = 9">❾</xsl:when> 125 <xsl:when test="$conum = 10">❿</xsl:when> 126 </xsl:choose> 127 </xsl:when> 128 <xsl:otherwise> 129 <xsl:message> 130 <xsl:text>Don't know how to generate Unicode callouts </xsl:text> 131 <xsl:text>when $callout.unicode.start.character is </xsl:text> 132 <xsl:value-of select="$callout.unicode.start.character"/> 133 </xsl:message> 134 <fo:inline background-color="#404040" 135 color="white" 136 padding-top="0.1em" 137 padding-bottom="0.1em" 138 padding-start="0.2em" 139 padding-end="0.2em" 140 baseline-shift="0.1em" 141 font-family="{$body.font.family}" 142 font-weight="bold" 143 font-size="75%"> 144 <xsl:value-of select="$conum"/> 145 </fo:inline> 146 </xsl:otherwise> 147 </xsl:choose> 148 </xsl:when> 149 150 <!-- Pick callouts from Zapf Dingbats - max 10 --> 151 <xsl:when test="$callout.dingbats != '0' and $conum <= 10"> 152 <fo:inline font-family="ZapfDingbats"> 153 <xsl:choose> 154 <xsl:when test="$conum=1">❶</xsl:when> 155 <xsl:when test="$conum=2">❷</xsl:when> 156 <xsl:when test="$conum=3">❸</xsl:when> 157 <xsl:when test="$conum=4">❹</xsl:when> 158 <xsl:when test="$conum=5">❺</xsl:when> 159 <xsl:when test="$conum=6">❻</xsl:when> 160 <xsl:when test="$conum=7">❼</xsl:when> 161 <xsl:when test="$conum=8">❽</xsl:when> 162 <xsl:when test="$conum=9">❾</xsl:when> 163 <xsl:when test="$conum=10">❿</xsl:when> 164 <xsl:otherwise><!-- overflow --> 165 <xsl:attribute name="color">red</xsl:attribute> 166 <xsl:text>●</xsl:text> 167 <xsl:message> 168 <xsl:text>A callout list contains more than 10 callouts;</xsl:text> 169 <xsl:text> callout numbering truncated.</xsl:text> 170 </xsl:message> 171 </xsl:otherwise> 172 </xsl:choose> 173 </fo:inline> 174 </xsl:when> 175 176 <!-- Most safe: draw a dark gray square with a white number inside --> 177 <xsl:otherwise> 178 <fo:inline background-color="#404040" 179 color="white" 180 padding-top="0.1em" 181 padding-bottom="0.1em" 182 padding-start="0.2em" 183 padding-end="0.2em" 184 baseline-shift="0.1em" 185 font-family="{$body.font.family}" 186 font-weight="bold" 187 font-size="75%"><xsl:value-of select="$conum"/></fo:inline> 188 </xsl:otherwise> 189 </xsl:choose> 190</xsl:template> 191 192</xsl:stylesheet> 193