~ubuntu-branches/ubuntu/utopic/yelp-xsl/utopic

« back to all changes in this revision

Viewing changes to xslt/docbook/common/db-xref.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-11-29 10:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20101129100013-1fxze8fm1fegxl8w
Tags: upstream-2.31.6
ImportĀ upstreamĀ versionĀ 2.31.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, write to the
 
15
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
16
02111-1307, USA.
 
17
-->
 
18
 
 
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
20
                xmlns:set="http://exslt.org/sets"
 
21
                xmlns:xl="http://www.w3.org/1999/xlink"
 
22
                xmlns:db="http://docbook.org/ns/docbook"
 
23
                exclude-result-prefixes="db xl set"
 
24
                version="1.0">
 
25
 
 
26
<!--!!==========================================================================
 
27
DocBook Links
 
28
:Requires: db-chunk db-title gettext
 
29
-->
 
30
 
 
31
 
 
32
<!--**==========================================================================
 
33
db.ulink.tooltip
 
34
Generates the tooltip for an external link
 
35
$node: The element to generate a tooltip for
 
36
$url: The URL of the link, usually from the #{url} attribute
 
37
-->
 
38
<xsl:template name="db.ulink.tooltip">
 
39
  <xsl:param name="node" select="."/>
 
40
  <xsl:param name="url" select="$node/@url | $node/@xl:href"/>
 
41
  <xsl:choose>
 
42
    <xsl:when test="starts-with($url, 'mailto:')">
 
43
      <xsl:variable name="addy" select="substring-after($url, 'mailto:')"/>
 
44
      <xsl:call-template name="l10n.gettext">
 
45
        <xsl:with-param name="msgid" select="'email.tooltip'"/>
 
46
        <xsl:with-param name="string" select="$addy"/>
 
47
        <xsl:with-param name="format" select="true()"/>
 
48
      </xsl:call-template>
 
49
    </xsl:when>
 
50
    <xsl:otherwise>
 
51
      <xsl:value-of select="normalize-space($url)"/>
 
52
    </xsl:otherwise>
 
53
  </xsl:choose>
 
54
</xsl:template>
 
55
 
 
56
 
 
57
<!--**==========================================================================
 
58
db.xref.content
 
59
Generates the content of a cross reference
 
60
$linkend: The id of the linked-to element, usually from the #{linkend} attribute
 
61
$target: The linked-to element
 
62
$xrefstyle: The cross reference style, usually from the #{xrefstyle} attribute
 
63
 
 
64
REMARK: The xrefstyle/role stuff needs to be documented
 
65
-->
 
66
<xsl:template name="db.xref.content">
 
67
  <xsl:param name="linkend" select="@linkend"/>
 
68
  <xsl:param name="target" select="key('idkey', $linkend)"/>
 
69
  <xsl:param name="xrefstyle" select="@xrefstyle"/>
 
70
  <xsl:choose>
 
71
    <xsl:when test="$xrefstyle = 'role:title'">
 
72
      <xsl:call-template name="db.title">
 
73
        <xsl:with-param name="node" select="$target"/>
 
74
      </xsl:call-template>
 
75
    </xsl:when>
 
76
    <xsl:when test="$xrefstyle = 'role:titleabbrev'">
 
77
      <xsl:call-template name="db.titleabbrev">
 
78
        <xsl:with-param name="node" select="$target"/>
 
79
      </xsl:call-template>
 
80
    </xsl:when>
 
81
    <xsl:when test="$xrefstyle = 'role:subtitle'">
 
82
      <xsl:call-template name="db.subtitle">
 
83
        <xsl:with-param name="node" select="$target"/>
 
84
      </xsl:call-template>
 
85
    </xsl:when>
 
86
    <xsl:when test="$target/@xreflabel">
 
87
      <xsl:value-of select="$target/@xreflabel"/>
 
88
    </xsl:when>
 
89
    <xsl:otherwise>
 
90
      <xsl:call-template name="db.title">
 
91
        <xsl:with-param name="node" select="$target"/>
 
92
      </xsl:call-template>
 
93
    </xsl:otherwise>
 
94
  </xsl:choose>
 
95
</xsl:template>
 
96
 
 
97
 
 
98
 
 
99
<!--**==========================================================================
 
100
db.xref.target
 
101
Generates the target identifier of a cross reference
 
102
$linkend: The id of the linked-to element, usually from the #{linkend} attribute
 
103
$target: The linked-to element
 
104
$is_chunk: Whether ${target} is known to be a chunked element
 
105
 
 
106
REMARK: Talk about how this works with chunking
 
107
-->
 
108
<xsl:template name="db.xref.target">
 
109
  <xsl:param name="linkend" select="@linkend"/>
 
110
  <xsl:param name="target" select="key('idkey', $linkend)"/>
 
111
  <xsl:param name="is_chunk" select="false()"/>
 
112
  <xsl:choose>
 
113
    <xsl:when test="$linkend = $db.chunk.info_basename">
 
114
      <xsl:value-of
 
115
       select="concat($db.chunk.info_basename, $db.chunk.extension)"/>
 
116
    </xsl:when>
 
117
    <xsl:when test="set:has-same-node($target, /*)">
 
118
      <xsl:value-of select="concat($db.chunk.basename, $db.chunk.extension)"/>
 
119
    </xsl:when>
 
120
    <xsl:when test="$is_chunk">
 
121
      <xsl:value-of select="concat($linkend, $db.chunk.extension)"/>
 
122
    </xsl:when>
 
123
    <xsl:otherwise>
 
124
      <xsl:variable name="target_chunk_id">
 
125
        <xsl:call-template name="db.chunk.chunk-id">
 
126
          <xsl:with-param name="node" select="$target"/>
 
127
        </xsl:call-template>
 
128
      </xsl:variable>
 
129
      <xsl:value-of select="concat($target_chunk_id, $db.chunk.extension)"/>
 
130
      <xsl:if test="string($linkend) != '' and string($target_chunk_id) != string($linkend)">
 
131
        <xsl:value-of select="concat('#', $linkend)"/>
 
132
      </xsl:if>
 
133
    </xsl:otherwise>
 
134
  </xsl:choose>
 
135
</xsl:template>
 
136
 
 
137
 
 
138
<!--**==========================================================================
 
139
db.xref.tooltip
 
140
Generates the tooltip for a cross reference
 
141
$linkend: The id of the linked-to element, usually from the #{linkend} attribute
 
142
$target: The linked-to element
 
143
 
 
144
REMARK: Document this
 
145
-->
 
146
<xsl:template name="db.xref.tooltip">
 
147
  <xsl:param name="linkend" select="@linkend"/>
 
148
  <xsl:param name="target" select="key('idkey', $linkend)"/>
 
149
  <xsl:apply-templates mode="db.xref.tooltip.mode" select="$target"/>
 
150
</xsl:template>
 
151
 
 
152
 
 
153
<!--%%==========================================================================
 
154
db.xref.tooltip.mode
 
155
FIXME
 
156
 
 
157
REMARK: Document this
 
158
-->
 
159
<xsl:template mode="db.xref.tooltip.mode" match="*">
 
160
  <xsl:call-template name="db.title">
 
161
    <xsl:with-param name="node" select="."/>
 
162
  </xsl:call-template>
 
163
</xsl:template>
 
164
 
 
165
<!-- = db.xref.tooltip.mode % biblioentry | bibliomixed = -->
 
166
<xsl:template mode="db.xref.tooltip.mode" match="biblioentry    | bibliomixed    |
 
167
                                                 db:biblioentry | db:bibliomixed ">
 
168
  <xsl:call-template name="l10n.gettext">
 
169
    <xsl:with-param name="msgid" select="'biblioentry.tooltip'"/>
 
170
    <xsl:with-param name="node" select="."/>
 
171
    <xsl:with-param name="format" select="true()"/>
 
172
  </xsl:call-template>
 
173
</xsl:template>
 
174
 
 
175
<!-- = db.xref.tooltip.mode % glossentry = -->
 
176
<xsl:template mode="db.xref.tooltip.mode" match="glossentry | db:glossentry">
 
177
  <xsl:call-template name="l10n.gettext">
 
178
    <xsl:with-param name="msgid" select="'glossentry.tooltip'"/>
 
179
    <xsl:with-param name="node" select="."/>
 
180
    <xsl:with-param name="format" select="true()"/>
 
181
  </xsl:call-template>
 
182
</xsl:template>
 
183
 
 
184
</xsl:stylesheet>