Debian Codegraph @

xslt/docbook/html/db2html-callout.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
3 This program is free software; you can redistribute it and/or modify it under
4 the terms of the GNU Lesser General Public License as published by the Free
5 Software Foundation; either version 2 of the License, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>.
15 -->
16
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:str="http://exslt.org/strings"
20 xmlns="http://www.w3.org/1999/xhtml"
21 exclude-result-prefixes="db str"
22 version="1.0">
23
24 <!--!!==========================================================================
25 DocBook to HTML - Callouts
26 @revision[version=1.0 date=2011-05-16 status=final]
27
28 This modules handles simple DocBook callouts using the `co` and `callout`
29 elements. Currently, only callouts to `co` elements are supported. The
30 `area` element is not supported.
31 -->
32
33
34 <!--**==========================================================================
35 db2html.callout.label
36 Create a callout label for a `co` element.
37 @revision[version=1.0 date=2011-05-16 status=final]
38
39 [xsl:params]
40 $node: The `co` element to create a callout label for.
41
42 This template creates a label for a callout, taking a `co` element as the
43 $node parameter. The label is numbered according to the position of the `co`
44 element in the document. To create the corresponding label for a `callout`
45 element, locate the corresponding `co` element and call this template on it.
46 -->
47 <xsl:template name="db2html.callout.label">
48 <xsl:param name="node" select="."/>
49 <span class="co">
50 <xsl:value-of select="count($node/preceding::co) + count($node/preceding::db:co) + 1"/>
51 </span>
52 </xsl:template>
53
54
55 <!-- == Matched Templates == -->
56
57 <!-- = co = -->
58 <xsl:template match="co | db:co">
59 <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
60 <xsl:if test="$if != ''">
61 <xsl:call-template name="db2html.callout.label"/>
62 </xsl:if>
63 </xsl:template>
64
65 <!-- = calloutlist = -->
66 <xsl:template match="calloutlist | db:calloutlist">
67 <xsl:call-template name="db2html.block.formal"/>
68 </xsl:template>
69
70 <!-- = callout == -->
71 <xsl:template match="callout | db:callout">
72 <xsl:variable name="node" select="."/>
73 <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
74 <xsl:if test="$if != ''">
75 <div>
76 <xsl:call-template name="html.class.attr">
77 <xsl:with-param name="class" select="'callout'"/>
78 </xsl:call-template>
79 <xsl:call-template name="html.lang.attrs"/>
80 <xsl:call-template name="db2html.anchor"/>
81 <div class="co">
82 <xsl:for-each select="str:split(@arearefs)">
83 <xsl:variable name="arearef" select="string(.)"/>
84 <xsl:for-each select="$node">
85 <xsl:variable name="co" select="key('db.id.key', $arearef)"/>
86 <xsl:if test="$co/self::co or $co/self::db:co">
87 <xsl:call-template name="db2html.callout.label">
88 <xsl:with-param name="node" select="$co"/>
89 </xsl:call-template>
90 </xsl:if>
91 </xsl:for-each>
92 </xsl:for-each>
93 </div>
94 <xsl:apply-templates/>
95 </div>
96 </xsl:if>
97 </xsl:template>
98
99 </xsl:stylesheet>