Debian Codegraph @

xslt/mallard/html/mal2html-gloss.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:mal="http://projectmallard.org/1.0/"
19 xmlns:cache="http://projectmallard.org/cache/1.0/"
20 xmlns:gloss="http://projectmallard.org/experimental/gloss/"
21 xmlns:exsl="http://exslt.org/common"
22 xmlns:str="http://exslt.org/strings"
23 xmlns="http://www.w3.org/1999/xhtml"
24 exclude-result-prefixes="mal cache gloss exsl str"
25 version="1.0">
26
27 <!--!!==========================================================================
28 Mallard to HTML - Glossaries
29 Support the Mallard Glossary extension.
30
31 This stylesheet contains templates and supporting JavaScript to support the
32 Mallard Glossary extension in HTML.
33 -->
34
35
36 <!--**==========================================================================
37 mal2html.gloss.terms
38 Display the glossary terms for a page or section.
39
40 [xsl:params]
41 $node: The glossary `page` or `section` to output terms for.
42
43 This template shows the glossary terms for a page or section. It collects the
44 terms with the {mal.gloss.terms} template, sorts them, and merges terms with
45 the same primary title. Terms that are not defined in the same page as $node
46 include a link to their defining page.
47 -->
48 <xsl:template name="mal2html.gloss.terms">
49 <xsl:param name="node" select="."/>
50 <xsl:variable name="pageid" select="$node/ancestor-or-self::mal:page[1]/@id"/>
51 <xsl:variable name="terms_">
52 <xsl:call-template name="mal.gloss.terms">
53 <xsl:with-param name="node" select="$node"/>
54 </xsl:call-template>
55 </xsl:variable>
56 <xsl:variable name="terms" select="exsl:node-set($terms_)/gloss:term"/>
57 <xsl:if test="count($terms) > 0">
58 <dl class="list gloss-list">
59 <xsl:for-each select="$terms">
60 <xsl:sort select="normalize-space(mal:title[1])"/>
61 <xsl:for-each select="mal:title">
62 <dt class="gloss-term">
63 <xsl:apply-templates mode="mal2html.inline.mode" select="node()"/>
64 </dt>
65 </xsl:for-each>
66 <xsl:for-each select="gloss:term">
67 <xsl:sort data-type="number" select="number(boolean(*[not(self::mal:title)]))"/>
68 <xsl:sort data-type="number" select="number(not(ancestor::mal:page[1]/@id = $pageid))"/>
69 <xsl:if test="not(@xref = $pageid)">
70 <dd class="gloss-link">
71 <a>
72 <xsl:attribute name="href">
73 <xsl:call-template name="mal.link.target">
74 <xsl:with-param name="xref" select="@xref"/>
75 </xsl:call-template>
76 </xsl:attribute>
77 <xsl:attribute name="title">
78 <xsl:call-template name="mal.link.tooltip">
79 <xsl:with-param name="xref" select="@xref"/>
80 <xsl:with-param name="role" select="'gloss:page'"/>
81 </xsl:call-template>
82 </xsl:attribute>
83 <xsl:call-template name="mal.link.content">
84 <xsl:with-param name="node" select="."/>
85 <xsl:with-param name="xref" select="@xref"/>
86 <xsl:with-param name="role" select="'gloss:page'"/>
87 </xsl:call-template>
88 </a>
89 </dd>
90 </xsl:if>
91 <xsl:if test="*[not(self::mal:title)]">
92 <dd class="gloss-def">
93 <xsl:apply-templates mode="mal2html.block.mode"
94 select="*[not(self::mal:title)]"/>
95 </dd>
96 </xsl:if>
97 </xsl:for-each>
98 </xsl:for-each>
99 </dl>
100 </xsl:if>
101 </xsl:template>
102
103 <xsl:template mode="mal2html.inline.mode" match="gloss:term">
104 <xsl:variable name="node" select="."/>
105 <a>
106 <xsl:call-template name="html.class.attr">
107 <xsl:with-param name="class" select="'gloss-term'"/>
108 </xsl:call-template>
109 <xsl:call-template name="html.lang.attrs"/>
110 <xsl:variable name="target">
111 <xsl:call-template name="mal.link.target">
112 <xsl:with-param name="node" select="$node"/>
113 </xsl:call-template>
114 </xsl:variable>
115 <xsl:choose>
116 <xsl:when test="$target = ''">
117 <xsl:attribute name="href">
118 <xsl:text>#</xsl:text>
119 </xsl:attribute>
120 </xsl:when>
121 <xsl:otherwise>
122 <xsl:attribute name="href">
123 <xsl:value-of select="$target"/>
124 </xsl:attribute>
125 </xsl:otherwise>
126 </xsl:choose>
127 <xsl:apply-templates mode="mal2html.inline.mode"/>
128 <xsl:for-each select="$mal.cache">
129 <xsl:variable name="terms" select="key('mal.gloss.key', $node/@ref)"/>
130 <xsl:for-each select="$terms/mal:info/mal:desc[1]">
131 <span class="gloss-desc">
132 <xsl:apply-templates mode="mal2html.inline.mode"/>
133 </span>
134 </xsl:for-each>
135 </xsl:for-each>
136 </a>
137 </xsl:template>
138
139 </xsl:stylesheet>