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