Debian Codegraph @

docbook-xsl-ns/xhtml/callout.xsl

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