Whamcloud - gitweb
LUDOC-120 presentation: build bits for webhelp.
[doc/manual.git] / webhelp / xhtml / callout.xsl
1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
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="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" version="1.0">
5
6 <!-- ********************************************************************
7      $Id: callout.xsl 9305 2012-04-27 21:50:53Z bobstayton $
8      ********************************************************************
9
10      This file is part of the XSL DocBook Stylesheet distribution.
11      See ../README or http://docbook.sf.net/release/xsl/current/ for
12      copyright 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>
48             <xsl:call-template name="common.html.attributes"/>
49             <xsl:call-template name="id.attribute"/>
50             <xsl:call-template name="number.rtf.lines">
51               <xsl:with-param name="rtf" select="$rtf-with-callouts"/>
52               <xsl:with-param name="pi.context" select="programlisting|screen"/>
53             </xsl:call-template>
54             <xsl:apply-templates select="calloutlist"/>
55           </div>
56         </xsl:when>
57         <xsl:otherwise>
58           <div>
59             <xsl:call-template name="common.html.attributes"/>
60             <xsl:call-template name="id.attribute"/>
61             <xsl:copy-of select="$rtf-with-callouts"/>
62             <xsl:apply-templates select="calloutlist"/>
63           </div>
64         </xsl:otherwise>
65       </xsl:choose>
66     </xsl:when>
67     <xsl:otherwise>
68       <div>
69         <xsl:apply-templates select="." mode="common.html.attributes"/>
70         <xsl:call-template name="id.attribute"/>
71         <xsl:apply-templates/>
72       </div>
73     </xsl:otherwise>
74   </xsl:choose>
75 </xsl:template>
76
77 <xsl:template match="areaspec|areaset|area">
78 </xsl:template>
79
80 <xsl:template match="areaset" mode="conumber">
81   <xsl:number count="area|areaset" format="1"/>
82 </xsl:template>
83
84 <xsl:template match="area" mode="conumber">
85   <xsl:number count="area|areaset" format="1"/>
86 </xsl:template>
87
88 <xsl:template match="co" name="co">
89   <!-- Support a single linkend in HTML -->
90   <xsl:variable name="targets" select="key('id', @linkends)"/>
91   <xsl:variable name="target" select="$targets[1]"/>
92   <xsl:choose>
93     <xsl:when test="$target">
94       <a>
95         <xsl:apply-templates select="." mode="common.html.attributes"/>
96         <xsl:choose>
97           <xsl:when test="$generate.id.attributes = 0">
98             <!-- force an id attribute here -->
99             <xsl:if test="@id or @xml:id">
100               <xsl:attribute name="id">
101                 <xsl:value-of select="(@id|@xml:id)[1]"/>
102               </xsl:attribute>
103             </xsl:if>
104           </xsl:when>
105           <xsl:otherwise>
106             <xsl:call-template name="id.attribute"/>
107           </xsl:otherwise>
108         </xsl:choose>
109         <xsl:attribute name="href">
110           <xsl:call-template name="href.target">
111             <xsl:with-param name="object" select="$target"/>
112           </xsl:call-template>
113         </xsl:attribute>
114         <xsl:apply-templates select="." mode="callout-bug"/>
115       </a>
116     </xsl:when>
117     <xsl:otherwise>
118       <xsl:if test="$generate.id.attributes != 0">
119         <xsl:if test="@id or @xml:id">
120           <span>
121              <xsl:attribute name="id">
122                 <xsl:value-of select="(@id|@xml:id)[1]"/>
123               </xsl:attribute>
124           </span>
125         </xsl:if>
126       </xsl:if>
127       <xsl:call-template name="anchor"/>
128       <xsl:apply-templates select="." mode="callout-bug"/>
129     </xsl:otherwise>
130   </xsl:choose>
131 </xsl:template>
132
133 <xsl:template match="coref">
134   <!-- tricky; this relies on the fact that we can process the "co" that's -->
135   <!-- "over there" as if it were "right here" -->
136
137   <xsl:variable name="co" select="key('id', @linkend)"/>
138   <xsl:choose>
139     <xsl:when test="not($co)">
140       <xsl:message>
141         <xsl:text>Error: coref link is broken: </xsl:text>
142         <xsl:value-of select="@linkend"/>
143       </xsl:message>
144     </xsl:when>
145     <xsl:when test="local-name($co) != 'co'">
146       <xsl:message>
147         <xsl:text>Error: coref doesn't point to a co: </xsl:text>
148         <xsl:value-of select="@linkend"/>
149       </xsl:message>
150     </xsl:when>
151     <xsl:otherwise>
152       <xsl:apply-templates select="$co"/>
153     </xsl:otherwise>
154   </xsl:choose>
155 </xsl:template>
156
157 <xsl:template match="co" mode="callout-bug">
158   <xsl:call-template name="callout-bug">
159     <xsl:with-param name="conum">
160       <xsl:number count="co" level="any" from="programlisting|screen|literallayout|synopsis" format="1"/>
161     </xsl:with-param>
162   </xsl:call-template>
163 </xsl:template>
164
165 <xsl:template name="callout-bug">
166   <xsl:param name="conum" select="1"/>
167
168   <xsl:choose>
169     <xsl:when test="$callout.graphics != 0                     and $conum &lt;= $callout.graphics.number.limit">
170       <!-- Added span to make valid in XHTML 1 -->
171       <span><img src="{$callout.graphics.path}{$conum}{$callout.graphics.extension}" alt="{$conum}" border="0"/></span>
172     </xsl:when>
173     <xsl:when test="$callout.unicode != 0                     and $conum &lt;= $callout.unicode.number.limit">
174       <xsl:choose>
175         <xsl:when test="$callout.unicode.start.character = 10102">
176           <xsl:choose>
177             <xsl:when test="$conum = 1">&#10102;</xsl:when>
178             <xsl:when test="$conum = 2">&#10103;</xsl:when>
179             <xsl:when test="$conum = 3">&#10104;</xsl:when>
180             <xsl:when test="$conum = 4">&#10105;</xsl:when>
181             <xsl:when test="$conum = 5">&#10106;</xsl:when>
182             <xsl:when test="$conum = 6">&#10107;</xsl:when>
183             <xsl:when test="$conum = 7">&#10108;</xsl:when>
184             <xsl:when test="$conum = 8">&#10109;</xsl:when>
185             <xsl:when test="$conum = 9">&#10110;</xsl:when>
186             <xsl:when test="$conum = 10">&#10111;</xsl:when>
187           </xsl:choose>
188         </xsl:when>
189         <xsl:otherwise>
190           <xsl:message>
191             <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
192             <xsl:text>when $callout.unicode.start.character is </xsl:text>
193             <xsl:value-of select="$callout.unicode.start.character"/>
194           </xsl:message>
195           <xsl:text>(</xsl:text>
196           <xsl:value-of select="$conum"/>
197           <xsl:text>)</xsl:text>
198         </xsl:otherwise>
199       </xsl:choose>
200     </xsl:when>
201     <xsl:otherwise>
202       <xsl:text>(</xsl:text>
203       <xsl:value-of select="$conum"/>
204       <xsl:text>)</xsl:text>
205     </xsl:otherwise>
206   </xsl:choose>
207 </xsl:template>
208
209 </xsl:stylesheet>