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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
<?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:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
xmlns:xverb="com.nwalsh.xalan.Verbatim"
xmlns:lxslt="http://xml.apache.org/xslt"
exclude-result-prefixes="sverb xverb lxslt"
version='1.0'>
<!-- ********************************************************************
$Id: callout.xsl,v 1.4 2005/07/15 08:27:48 techtonik Exp $
********************************************************************
This file is part of the XSL DocBook Stylesheet distribution.
See ../README or http://nwalsh.com/docbook/xsl/ for copyright
and other information.
******************************************************************** -->
<lxslt:component prefix="xverb"
functions="insertCallouts"/>
<xsl:template match="programlistingco|screenco">
<xsl:variable name="verbatim" select="programlisting|screen"/>
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
<xsl:choose>
<xsl:when test="$use.extensions != '0'
and $callouts.extension != '0'">
<xsl:variable name="rtf">
<xsl:apply-templates select="$verbatim">
<xsl:with-param name="suppress-numbers" select="'1'"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:variable name="rtf-with-callouts">
<xsl:choose>
<xsl:when test="contains($vendor, 'SAXON ')">
<xsl:copy-of select="sverb:insertCallouts(areaspec,$rtf)"/>
</xsl:when>
<xsl:when test="contains($vendor, 'Apache Software Foundation')">
<xsl:copy-of select="xverb:insertCallouts(areaspec,$rtf)"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:text>Don't know how to do callouts with </xsl:text>
<xsl:value-of select="$vendor"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$verbatim/@linenumbering = 'numbered'
and $linenumbering.extension != '0'">
<xsl:call-template name="number.rtf.lines">
<xsl:with-param name="rtf" select="$rtf-with-callouts"/>
<xsl:with-param name="pi.context"
select="programlisting|screen"/>
</xsl:call-template>
<xsl:apply-templates select="calloutlist"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$rtf-with-callouts"/>
<xsl:apply-templates select="calloutlist"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="areaspec|areaset|area">
</xsl:template>
<xsl:template match="areaset" mode="conumber">
<xsl:number count="area|areaset" format="1"/>
</xsl:template>
<xsl:template match="area" mode="conumber">
<xsl:number count="area|areaset" format="1"/>
</xsl:template>
<xsl:template match="co">
<fo:inline id="{@id}">
<xsl:apply-templates select="." mode="callout-bug"/>
</fo:inline>
</xsl:template>
<xsl:template match="coref">
<!-- tricky; this relies on the fact that we can process the "co" that's -->
<!-- "over there" as if it were "right here" -->
<xsl:variable name="co" select="key('id', @linkend)"/>
<xsl:variable name="id" select="@id"/>
<xsl:choose>
<xsl:when test="not($co)">
<xsl:message>
<xsl:text>Error: coref link is broken: </xsl:text>
<xsl:value-of select="@linkend"/>
</xsl:message>
</xsl:when>
<xsl:when test="local-name($co) != 'co'">
<xsl:message>
<xsl:text>Error: coref doesn't point to a co: </xsl:text>
<xsl:value-of select="@linkend"/>
</xsl:message>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:if test="$id != ''">
<xsl:attribute name="id">
<xsl:value-of select="$id"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="$co" mode="callout-bug"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="co" mode="callout-bug">
<xsl:call-template name="callout-bug">
<xsl:with-param name="conum">
<xsl:number count="co"
level="any"
from="programlisting|screen|literallayout|synopsis"
format="1"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="callout-bug">
<xsl:param name="conum" select='1'/>
<xsl:choose>
<!-- Draw callouts as images -->
<xsl:when test="$callout.graphics != '0'
and $conum <= $callout.graphics.number.limit">
<xsl:variable name="filename"
select="concat($callout.graphics.path,$conum,$callout.graphics.extension)"/>
<fo:external-graphic>
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="$passivetex.extensions != 0
or $fop.extensions != 0
or $arbortext.extensions != 0">
<xsl:value-of select="$filename"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>url(</xsl:text>
<xsl:value-of select="$filename"/>
<xsl:text>)</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</fo:external-graphic>
</xsl:when>
<xsl:when test="$callout.unicode != 0
and $conum <= $callout.unicode.number.limit">
<xsl:variable name="comarkup">
<xsl:choose>
<xsl:when test="$callout.unicode.start.character = 10102">
<xsl:choose>
<xsl:when test="$conum = 1">❶</xsl:when>
<xsl:when test="$conum = 2">❷</xsl:when>
<xsl:when test="$conum = 3">❸</xsl:when>
<xsl:when test="$conum = 4">❹</xsl:when>
<xsl:when test="$conum = 5">❺</xsl:when>
<xsl:when test="$conum = 6">❻</xsl:when>
<xsl:when test="$conum = 7">❼</xsl:when>
<xsl:when test="$conum = 8">❽</xsl:when>
<xsl:when test="$conum = 9">❾</xsl:when>
<xsl:when test="$conum = 10">❿</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>Don't know how to generate Unicode callouts </xsl:text>
<xsl:text>when $callout.unicode.start.character is </xsl:text>
<xsl:value-of select="$callout.unicode.start.character"/>
</xsl:message>
<fo:inline background-color="#404040"
color="white"
padding-top="0.1em"
padding-bottom="0.1em"
padding-start="0.2em"
padding-end="0.2em"
baseline-shift="0.1em"
font-family="{$body.fontset}"
font-weight="bold"
font-size="75%">
<xsl:value-of select="$conum"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$callout.unicode.font != ''">
<fo:inline font-family="{$callout.unicode.font}">
<xsl:copy-of select="$comarkup"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$comarkup"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Most safe: draw a dark gray square with a white number inside -->
<xsl:otherwise>
<fo:inline background-color="#404040"
color="white"
padding-top="0.1em"
padding-bottom="0.1em"
padding-start="0.2em"
padding-end="0.2em"
baseline-shift="0.1em"
font-family="{$body.fontset}"
font-weight="bold"
font-size="75%">
<xsl:value-of select="$conum"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|