Release 0.34.18
[vala-gnome.git] / doc / manual / xhtml.xsl
blob43420bc320b595d944207504481111b44ef2d5bd
1 <?xml version="1.0"?>
2 <xsl:stylesheet
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version="1.0"
5 xmlns:str="http://exslt.org/strings"
6 xmlns:exsl="http://exslt.org/common"
7 extension-element-prefixes="exsl"
8 exclude-result-prefixes="str"
11 <xsl:import href="common.xsl"/>
13 <xsl:output
14 method="html"
15 indent="yes"
16 omit-xml-declaration="yes"
17 encoding="UTF-8"
18 media-type="text/html"
21 <xsl:template match="/">
22 <xsl:call-template name="html5-doctype"/>
23 <html><xsl:call-template name="whitespace-newline"/>
24 <head><xsl:call-template name="whitespace-newline"/>
25 <xsl:apply-templates select="article/section/title[1]" mode="html-head"/>
26 </head><xsl:call-template name="whitespace-newline"/>
27 <body><xsl:call-template name="whitespace-newline"/>
28 <xsl:apply-templates select="article" mode="toc"/>
29 </body><xsl:call-template name="whitespace-newline"/>
30 </html>
31 </xsl:template>
33 <xsl:template match="article/section/section">
34 <xsl:variable name="path">
35 <xsl:call-template name="normalizepath">
36 <xsl:with-param name="title" select="title"/>
37 </xsl:call-template>
38 </xsl:variable>
39 <exsl:document
40 href="{$path}.html"
41 method="html"
42 indent="yes"
43 omit-xml-declaration="yes"
45 <xsl:call-template name="html5-doctype"/>
46 <html>
47 <head>
48 <xsl:apply-templates select="title" mode="html-head"/>
49 </head>
50 <body>
51 <div class="header">
52 <a href="index.html"><xsl:value-of select="/article/section/title"/></a>
53 </div>
54 <xsl:apply-templates select="title"/>
55 <xsl:if test="count(section) > 0">
56 <ul class="page_toc">
57 <xsl:for-each select="section">
58 <li>
59 <xsl:call-template name="linkto">
60 <xsl:with-param name="page" select="../title"/>
61 <xsl:with-param name="subpage" select="title"/>
62 <xsl:with-param name="title" select="title"/>
63 </xsl:call-template>
64 </li>
65 </xsl:for-each>
66 </ul>
67 </xsl:if>
68 <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist"/>
69 </body>
70 </html>
71 </exsl:document>
72 </xsl:template>
74 <xsl:template name="html5-doctype">
75 <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
76 <xsl:call-template name="whitespace-newline"/>
77 </xsl:template>
79 <xsl:template match="*" mode="html5-charset">
80 <xsl:text disable-output-escaping='yes'>&lt;meta charset="UTF-8" /&gt;</xsl:text>
81 <xsl:call-template name="whitespace-newline"/>
82 </xsl:template>
84 <xsl:template name="whitespace-newline">
85 <xsl:text>&#10;</xsl:text>
86 </xsl:template>
88 <xsl:template match="title" mode="html-head">
89 <xsl:apply-templates select="." mode="html5-charset"/>
90 <title><xsl:value-of select="text()"/> - <xsl:value-of select="/article/section/title"/></title>
91 <link rel="stylesheet" type="text/css" href="default.css"/>
92 </xsl:template>
94 <xsl:template match="article">
95 <xsl:apply-templates select="articleinfo|section"/>
96 </xsl:template>
98 <xsl:template match="article/section/title">
99 <div class="header">
100 <a href="index.html"><xsl:value-of select="."/></a>
101 </div>
102 <h1><xsl:value-of select="."/></h1>
103 </xsl:template>
105 <xsl:template match="article/section" mode="toc">
106 <xsl:apply-templates select="title"/>
107 <ul class="toc">
108 <xsl:for-each select="section">
109 <li>
110 <xsl:call-template name="linkto">
111 <xsl:with-param name="page" select="title"/>
112 <xsl:with-param name="title" select="title"/>
113 </xsl:call-template>
114 <xsl:if test="count(section) > 0">
115 <xsl:call-template name="whitespace-newline"/>
116 <ul>
117 <xsl:for-each select="section">
118 <li>
119 <xsl:call-template name="linkto">
120 <xsl:with-param name="page" select="../title"/>
121 <xsl:with-param name="subpage" select="title"/>
122 <xsl:with-param name="title" select="title"/>
123 </xsl:call-template>
124 </li>
125 </xsl:for-each>
126 </ul>
127 </xsl:if>
128 </li>
129 </xsl:for-each>
130 </ul>
131 <xsl:apply-templates select="section"/>
132 </xsl:template>
134 <xsl:template match="article/section/section/title">
135 <h2><xsl:value-of select="."/></h2>
136 </xsl:template>
138 <xsl:template match="article/section/section/section">
139 <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
140 </xsl:template>
142 <xsl:template match="article/section/section/section/title">
143 <xsl:variable name="id">
144 <xsl:call-template name="normalizepath">
145 <xsl:with-param name="title" select="."/>
146 </xsl:call-template>
147 </xsl:variable>
148 <xsl:call-template name="whitespace-newline"/>
149 <xsl:call-template name="whitespace-newline"/>
150 <h3 id="{$id}"><xsl:value-of select="."/></h3>
151 </xsl:template>
153 <xsl:template match="article/section/section/section/section">
154 <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
155 </xsl:template>
157 <xsl:template match="article/section/section/section/section/title">
158 <xsl:variable name="id">
159 <xsl:call-template name="normalizepath">
160 <xsl:with-param name="title" select="."/>
161 </xsl:call-template>
162 </xsl:variable>
163 <h4><xsl:value-of select="."/><a name="{$id}">&#160;</a></h4>
164 </xsl:template>
166 <xsl:template match="para">
167 <p><xsl:apply-templates select="text()|code|ulink|emphasis"/></p>
168 </xsl:template>
170 <xsl:template match="emphasis">
171 <strong><xsl:apply-templates select="text()"/></strong>
172 </xsl:template>
174 <xsl:template match="ulink">
175 <xsl:if test="starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/')">
176 <xsl:variable name="pageid">
177 <xsl:call-template name="normalizepath">
178 <xsl:with-param name="title" select="str:decode-uri(str:tokenize(substring-after(@url, 'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[1])"/>
179 </xsl:call-template>
180 </xsl:variable>
181 <a href="{$pageid}.html#{str:tokenize(substring-after(@url, 'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[2]}"><xsl:value-of select="."/></a>
182 </xsl:if>
183 <xsl:if test="not(starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'))">
184 <a href="{@url}"><xsl:value-of select="."/></a>
185 </xsl:if>
186 </xsl:template>
189 <xsl:template match="para/code">
190 <xsl:if test="contains (text(), '&#x0a;')">
191 <pre><xsl:value-of select="text()"/></pre>
192 </xsl:if>
193 <xsl:if test="not (contains (text(), '&#x0a;'))">
194 <code><xsl:value-of select="text()"/></code>
195 </xsl:if>
196 </xsl:template>
198 <xsl:template match="screen">
199 <pre><xsl:value-of select="text()"/></pre>
200 </xsl:template>
202 <!-- program listing -->
203 <xsl:template match="programlisting">
204 <pre class="o-box c-program"><xsl:apply-templates select="text()|type|methodname|token|phrase|lineannotation"/></pre>
205 </xsl:template>
207 <xsl:template match="type">
208 <span class="c-program-type"><xsl:value-of select="."/></span>
209 </xsl:template>
211 <xsl:template match="token">
212 <span class="c-program-token"><xsl:value-of select="."/></span>
213 </xsl:template>
215 <xsl:template match="methodname">
216 <span class="c-program-methodname"><xsl:value-of select="."/></span>
217 </xsl:template>
219 <xsl:template match="lineannotation">
220 <span class="c-program-comment"><xsl:value-of select="."/></span>
221 </xsl:template>
223 <xsl:template match="phrase">
224 <span class="c-program-phrase"><xsl:value-of select="."/></span>
225 </xsl:template>
227 <xsl:template match="programlisting/text()[. = '&#10;'][preceding-sibling::*[1][self::phrase]]">
228 <span class="c-program-phrase"><xsl:text>\n</xsl:text></span>
229 </xsl:template>
231 <xsl:template match="programlisting/text()[. = '&#10;&#10;'][preceding-sibling::*[1][self::phrase]]">
232 <span class="c-program-phrase"><xsl:text>\n\n</xsl:text></span>
233 </xsl:template>
235 <!-- lists -->
236 <xsl:template match="itemizedlist[listitem[not(@override)]]">
237 <ul><xsl:apply-templates select="listitem"/></ul>
238 </xsl:template>
240 <xsl:template match="listitem[not(@override)]">
241 <li><xsl:apply-templates select="para"/></li>
242 </xsl:template>
244 <xsl:template match="itemizedlist[listitem[@override='none']]">
245 <blockquote class="o-box c-rules"><xsl:apply-templates select="listitem"/></blockquote>
246 </xsl:template>
248 <xsl:template match="listitem[@override='none']/itemizedlist"><xsl:apply-templates select="listitem"/><xsl:text>
249 </xsl:text></xsl:template>
251 <xsl:template match="listitem[@override='none']">
252 <xsl:apply-templates select="para|itemizedlist"/>
253 </xsl:template>
255 <xsl:template match="listitem[@override='none']/para"><xsl:apply-templates select="text()|emphasis"/><xsl:text>
256 </xsl:text></xsl:template>
258 <xsl:template match="listitem[@override='none']/para/text()">
259 <xsl:if test="position()=1 and starts-with(.,' ')">
260 <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="substring-after(.,' ')"/></xsl:if>
261 </xsl:if>
262 <xsl:if test="position()!=1 or not(starts-with(.,' '))">
263 <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="."/></xsl:if>
264 </xsl:if>
265 </xsl:template>
267 <xsl:template match="listitem[@override='none']/para/emphasis[@role='strong']"><span class="literal"><xsl:value-of select="."/></span></xsl:template>
268 <xsl:template match="listitem[@override='none']/itemizedlist/listitem[@override='none']/para"><xsl:text>&#x09;</xsl:text><xsl:apply-templates select="text()|emphasis"/><xsl:text>
269 </xsl:text></xsl:template>
271 <!-- tables -->
272 <xsl:template match="informaltable">
273 <table class="c-informaltable">
274 <xsl:apply-templates select="tgroup/tbody/row"/>
275 </table>
276 </xsl:template>
278 <xsl:template match="row">
279 <tr>
280 <xsl:apply-templates select="entry"/>
281 </tr>
282 </xsl:template>
284 <xsl:template match="entry">
285 <td xsl:use-attribute-sets="entry-attrs">
286 <xsl:apply-templates select="para"/>
287 </td>
288 </xsl:template>
290 <xsl:attribute-set name="entry-attrs">
291 <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
292 <xsl:attribute name="colspan">
293 <xsl:if test="@nameend"><xsl:value-of select="number(substring-after(@nameend, 'col_'))+1"/></xsl:if>
294 </xsl:attribute>
295 </xsl:attribute-set>
297 </xsl:stylesheet>