| 1 | <?xml version='1.0'?>
|
|---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|---|
| 3 | xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
|
|---|
| 4 | xmlns:xverb="com.nwalsh.xalan.Verbatim"
|
|---|
| 5 | xmlns:lxslt="http://xml.apache.org/xslt"
|
|---|
| 6 | exclude-result-prefixes="sverb xverb lxslt"
|
|---|
| 7 | version='1.0'>
|
|---|
| 8 |
|
|---|
| 9 | <!-- ********************************************************************
|
|---|
| 10 | $Id: callout.xsl,v 1.11 2003/08/07 17:04:43 bobstayton Exp $
|
|---|
| 11 | ********************************************************************
|
|---|
| 12 |
|
|---|
| 13 | This file is part of the XSL DocBook Stylesheet distribution.
|
|---|
| 14 | See ../README or http://nwalsh.com/docbook/xsl/ for copyright
|
|---|
| 15 | and other information.
|
|---|
| 16 |
|
|---|
| 17 | ******************************************************************** -->
|
|---|
| 18 |
|
|---|
| 19 | <lxslt:component prefix="xverb"
|
|---|
| 20 | functions="insertCallouts"/>
|
|---|
| 21 |
|
|---|
| 22 | <xsl:template match="programlistingco|screenco">
|
|---|
| 23 | <xsl:variable name="verbatim" select="programlisting|screen"/>
|
|---|
| 24 |
|
|---|
| 25 | <xsl:choose>
|
|---|
| 26 | <xsl:when test="$use.extensions != '0'
|
|---|
| 27 | and $callouts.extension != '0'">
|
|---|
| 28 | <xsl:variable name="rtf">
|
|---|
| 29 | <xsl:apply-templates select="$verbatim">
|
|---|
| 30 | <xsl:with-param name="suppress-numbers" select="'1'"/>
|
|---|
| 31 | </xsl:apply-templates>
|
|---|
| 32 | </xsl:variable>
|
|---|
| 33 |
|
|---|
| 34 | <xsl:variable name="rtf-with-callouts">
|
|---|
| 35 | <xsl:choose>
|
|---|
| 36 | <xsl:when test="function-available('sverb:insertCallouts')">
|
|---|
| 37 | <xsl:copy-of select="sverb:insertCallouts(areaspec,$rtf)"/>
|
|---|
| 38 | </xsl:when>
|
|---|
| 39 | <xsl:when test="function-available('xverb:insertCallouts')">
|
|---|
| 40 | <xsl:copy-of select="xverb:insertCallouts(areaspec,$rtf)"/>
|
|---|
| 41 | </xsl:when>
|
|---|
| 42 | <xsl:otherwise>
|
|---|
| 43 | <xsl:message terminate="yes">
|
|---|
| 44 | <xsl:text>No insertCallouts function is available.</xsl:text>
|
|---|
| 45 | </xsl:message>
|
|---|
| 46 | </xsl:otherwise>
|
|---|
| 47 | </xsl:choose>
|
|---|
| 48 | </xsl:variable>
|
|---|
| 49 |
|
|---|
| 50 | <xsl:choose>
|
|---|
| 51 | <xsl:when test="$verbatim/@linenumbering = 'numbered'
|
|---|
| 52 | and $linenumbering.extension != '0'">
|
|---|
| 53 | <div class="{name(.)}">
|
|---|
| 54 | <xsl:call-template name="number.rtf.lines">
|
|---|
| 55 | <xsl:with-param name="rtf" select="$rtf-with-callouts"/>
|
|---|
| 56 | <xsl:with-param name="pi.context"
|
|---|
| 57 | select="programlisting|screen"/>
|
|---|
| 58 | </xsl:call-template>
|
|---|
| 59 | <xsl:apply-templates select="calloutlist"/>
|
|---|
| 60 | </div>
|
|---|
| 61 | </xsl:when>
|
|---|
| 62 | <xsl:otherwise>
|
|---|
| 63 | <div class="{name(.)}">
|
|---|
| 64 | <xsl:copy-of select="$rtf-with-callouts"/>
|
|---|
| 65 | <xsl:apply-templates select="calloutlist"/>
|
|---|
| 66 | </div>
|
|---|
| 67 | </xsl:otherwise>
|
|---|
| 68 | </xsl:choose>
|
|---|
| 69 | </xsl:when>
|
|---|
| 70 | <xsl:otherwise>
|
|---|
| 71 | <div class="{name(.)}">
|
|---|
| 72 | <xsl:apply-templates/>
|
|---|
| 73 | </div>
|
|---|
| 74 | </xsl:otherwise>
|
|---|
| 75 | </xsl:choose>
|
|---|
| 76 | </xsl:template>
|
|---|
| 77 |
|
|---|
| 78 | <xsl:template match="areaspec|areaset|area">
|
|---|
| 79 | </xsl:template>
|
|---|
| 80 |
|
|---|
| 81 | <xsl:template match="areaset" mode="conumber">
|
|---|
| 82 | <xsl:number count="area|areaset" format="1"/>
|
|---|
| 83 | </xsl:template>
|
|---|
| 84 |
|
|---|
| 85 | <xsl:template match="area" mode="conumber">
|
|---|
| 86 | <xsl:number count="area|areaset" format="1"/>
|
|---|
| 87 | </xsl:template>
|
|---|
| 88 |
|
|---|
| 89 | <xsl:template match="co" name="co">
|
|---|
| 90 | <!-- Support a single linkend in HTML -->
|
|---|
| 91 | <xsl:variable name="targets" select="key('id', @linkends)"/>
|
|---|
| 92 | <xsl:variable name="target" select="$targets[1]"/>
|
|---|
| 93 | <xsl:choose>
|
|---|
| 94 | <xsl:when test="$target">
|
|---|
| 95 | <a>
|
|---|
| 96 | <xsl:if test="@id">
|
|---|
| 97 | <xsl:attribute name="name">
|
|---|
| 98 | <xsl:value-of select="@id"/>
|
|---|
| 99 | </xsl:attribute>
|
|---|
| 100 | </xsl:if>
|
|---|
| 101 | <xsl:attribute name="href">
|
|---|
| 102 | <xsl:call-template name="href.target">
|
|---|
| 103 | <xsl:with-param name="object" select="$target"/>
|
|---|
| 104 | </xsl:call-template>
|
|---|
| 105 | </xsl:attribute>
|
|---|
| 106 | <xsl:apply-templates select="." mode="callout-bug"/>
|
|---|
| 107 | </a>
|
|---|
| 108 | </xsl:when>
|
|---|
| 109 | <xsl:otherwise>
|
|---|
| 110 | <xsl:call-template name="anchor"/>
|
|---|
| 111 | <xsl:apply-templates select="." mode="callout-bug"/>
|
|---|
| 112 | </xsl:otherwise>
|
|---|
| 113 | </xsl:choose>
|
|---|
| 114 | </xsl:template>
|
|---|
| 115 |
|
|---|
| 116 | <xsl:template match="coref">
|
|---|
| 117 | <!-- tricky; this relies on the fact that we can process the "co" that's -->
|
|---|
| 118 | <!-- "over there" as if it were "right here" -->
|
|---|
| 119 |
|
|---|
| 120 | <xsl:variable name="co" select="key('id', @linkend)"/>
|
|---|
| 121 | <xsl:choose>
|
|---|
| 122 | <xsl:when test="not($co)">
|
|---|
| 123 | <xsl:message>
|
|---|
| 124 | <xsl:text>Error: coref link is broken: </xsl:text>
|
|---|
| 125 | <xsl:value-of select="@linkend"/>
|
|---|
| 126 | </xsl:message>
|
|---|
| 127 | </xsl:when>
|
|---|
| 128 | <xsl:when test="local-name($co) != 'co'">
|
|---|
| 129 | <xsl:message>
|
|---|
| 130 | <xsl:text>Error: coref doesn't point to a co: </xsl:text>
|
|---|
| 131 | <xsl:value-of select="@linkend"/>
|
|---|
| 132 | </xsl:message>
|
|---|
| 133 | </xsl:when>
|
|---|
| 134 | <xsl:otherwise>
|
|---|
| 135 | <xsl:apply-templates select="$co"/>
|
|---|
| 136 | </xsl:otherwise>
|
|---|
| 137 | </xsl:choose>
|
|---|
| 138 | </xsl:template>
|
|---|
| 139 |
|
|---|
| 140 | <xsl:template match="co" mode="callout-bug">
|
|---|
| 141 | <xsl:call-template name="callout-bug">
|
|---|
| 142 | <xsl:with-param name="conum">
|
|---|
| 143 | <xsl:number count="co"
|
|---|
| 144 | level="any"
|
|---|
| 145 | from="programlisting|screen|literallayout|synopsis"
|
|---|
| 146 | format="1"/>
|
|---|
| 147 | </xsl:with-param>
|
|---|
| 148 | </xsl:call-template>
|
|---|
| 149 | </xsl:template>
|
|---|
| 150 |
|
|---|
| 151 | <xsl:template name="callout-bug">
|
|---|
| 152 | <xsl:param name="conum" select='1'/>
|
|---|
| 153 |
|
|---|
| 154 | <xsl:choose>
|
|---|
| 155 | <xsl:when test="$callout.graphics != 0
|
|---|
| 156 | and $conum <= $callout.graphics.number.limit">
|
|---|
| 157 | <img src="{$callout.graphics.path}{$conum}{$callout.graphics.extension}"
|
|---|
| 158 | alt="{$conum}" border="0"/>
|
|---|
| 159 | </xsl:when>
|
|---|
| 160 | <xsl:when test="$callout.unicode != 0
|
|---|
| 161 | and $conum <= $callout.unicode.number.limit">
|
|---|
| 162 | <xsl:choose>
|
|---|
| 163 | <xsl:when test="$callout.unicode.start.character = 10102">
|
|---|
| 164 | <xsl:choose>
|
|---|
| 165 | <xsl:when test="$conum = 1">❶</xsl:when>
|
|---|
| 166 | <xsl:when test="$conum = 2">❷</xsl:when>
|
|---|
| 167 | <xsl:when test="$conum = 3">❸</xsl:when>
|
|---|
| 168 | <xsl:when test="$conum = 4">❹</xsl:when>
|
|---|
| 169 | <xsl:when test="$conum = 5">❺</xsl:when>
|
|---|
| 170 | <xsl:when test="$conum = 6">❻</xsl:when>
|
|---|
| 171 | <xsl:when test="$conum = 7">❼</xsl:when>
|
|---|
| 172 | <xsl:when test="$conum = 8">❽</xsl:when>
|
|---|
| 173 | <xsl:when test="$conum = 9">❾</xsl:when>
|
|---|
| 174 | <xsl:when test="$conum = 10">❿</xsl:when>
|
|---|
| 175 | </xsl:choose>
|
|---|
| 176 | </xsl:when>
|
|---|
| 177 | <xsl:otherwise>
|
|---|
| 178 | <xsl:message>
|
|---|
| 179 | <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
|
|---|
| 180 | <xsl:text>when $callout.unicode.start.character is </xsl:text>
|
|---|
| 181 | <xsl:value-of select="$callout.unicode.start.character"/>
|
|---|
| 182 | </xsl:message>
|
|---|
| 183 | <xsl:text>(</xsl:text>
|
|---|
| 184 | <xsl:value-of select="$conum"/>
|
|---|
| 185 | <xsl:text>)</xsl:text>
|
|---|
| 186 | </xsl:otherwise>
|
|---|
| 187 | </xsl:choose>
|
|---|
| 188 | </xsl:when>
|
|---|
| 189 | <xsl:otherwise>
|
|---|
| 190 | <xsl:text>(</xsl:text>
|
|---|
| 191 | <xsl:value-of select="$conum"/>
|
|---|
| 192 | <xsl:text>)</xsl:text>
|
|---|
| 193 | </xsl:otherwise>
|
|---|
| 194 | </xsl:choose>
|
|---|
| 195 | </xsl:template>
|
|---|
| 196 |
|
|---|
| 197 | </xsl:stylesheet>
|
|---|