vala: Use CodeContext.root instead of SemanticAnalyzer.root_symbol
[vala-gnome.git] / doc / manual / common.xsl
blob2a802b52d5bdc0ccdea1538d05ad936cb1af6b03
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 xmlns:date="http://exslt.org/dates-and-times"
8 extension-element-prefixes="exsl"
9 exclude-result-prefixes="str date"
12 <xsl:template name="normalizepath">
13 <xsl:param name="title"/>
14 <xsl:variable name="space-to-underscore" select="str:replace($title, ' ', '_')"/>
15 <xsl:variable name="open-parens-to-underscore" select="str:replace($space-to-underscore, '(', '_')"/>
16 <xsl:value-of select="str:replace($open-parens-to-underscore, ')', '_')"/>
17 </xsl:template>
19 <xsl:template name="linkto">
20 <xsl:param name="page"/>
21 <xsl:param name="subpage"/>
22 <xsl:param name="title"/>
23 <xsl:variable name="path">
24 <xsl:call-template name="normalizepath">
25 <xsl:with-param name="title" select="$page"/>
26 </xsl:call-template>
27 </xsl:variable>
28 <xsl:variable name="fragment">
29 <xsl:call-template name="normalizepath">
30 <xsl:with-param name="title" select="$subpage"/>
31 </xsl:call-template>
32 </xsl:variable>
33 <xsl:choose>
34 <xsl:when test="$fragment=''">
35 <a href="{$path}.html"><xsl:value-of select="$title"/></a>
36 </xsl:when>
37 <xsl:when test="$page='' and $fragment!=''">
38 <a href="#{$fragment}"><xsl:value-of select="$title"/></a>
39 </xsl:when>
40 <xsl:otherwise>
41 <a href="{$path}.html#{$fragment}"><xsl:value-of select="$title"/></a>
42 </xsl:otherwise>
43 </xsl:choose>
44 </xsl:template>
46 <xsl:template name="html5-doctype">
47 <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
48 <xsl:call-template name="whitespace-newline"/>
49 </xsl:template>
51 <xsl:template match="*" mode="html5-charset">
52 <xsl:text disable-output-escaping='yes'>&lt;meta charset="UTF-8" /&gt;</xsl:text>
53 <xsl:call-template name="whitespace-newline"/>
54 </xsl:template>
56 <xsl:template name="html-no-initial-scaling">
57 <xsl:text disable-output-escaping='yes'>&lt;meta name="viewport" content="initial-scale=1"&gt;</xsl:text>
58 <xsl:call-template name="whitespace-newline"/>
59 </xsl:template>
61 <xsl:template name="whitespace-newline">
62 <xsl:text>&#10;</xsl:text>
63 </xsl:template>
65 <xsl:template match="title" mode="html-head">
66 <xsl:apply-templates select="." mode="html5-charset"/>
67 <title><xsl:value-of select="text()"/> - <xsl:value-of select="/article/section/title"/></title>
68 <link rel="stylesheet" type="text/css" href="default.css"/>
69 </xsl:template>
71 <xsl:template match="article">
72 <xsl:apply-templates select="articleinfo|section"/>
73 </xsl:template>
75 <xsl:template match="article/section" mode="toc">
76 <h1><xsl:apply-templates select="title"/></h1>
77 <xsl:apply-templates select="document('version.xml')/articleinfo" mode="toc"/>
78 <ul class="toc">
79 <xsl:for-each select="section">
80 <li>
81 <xsl:call-template name="linkto">
82 <xsl:with-param name="title">
83 <xsl:apply-templates select="title" mode="numbered-level-one"/>
84 </xsl:with-param>
85 <xsl:with-param name="page" select="title"/>
86 </xsl:call-template>
87 <xsl:if test="count(section) > 0">
88 <xsl:call-template name="whitespace-newline"/>
89 <ul>
90 <xsl:for-each select="section">
91 <li>
92 <xsl:call-template name="linkto">
93 <xsl:with-param name="title">
94 <xsl:apply-templates select="title" mode="numbered-level-two"/>
95 </xsl:with-param>
96 <xsl:with-param name="page" select="../title"/>
97 <xsl:with-param name="subpage" select="title"/>
98 </xsl:call-template>
99 </li>
100 </xsl:for-each>
101 </ul>
102 </xsl:if>
103 </li>
104 </xsl:for-each>
105 </ul>
106 <xsl:apply-templates select="section"/>
107 </xsl:template>
109 <xsl:template match="articleinfo" mode="toc">
110 <xsl:apply-templates select="abstract"/>
111 <table class="c-document_version">
112 <tr><td>Vala version:</td><td><xsl:apply-templates select="edition"/></td></tr>
113 <tr><td>Release:</td><td><xsl:apply-templates select="releaseinfo/text()"/></td></tr>
114 <tr><td>Status:</td><td><xsl:apply-templates select="releaseinfo/remark"/></td></tr>
115 <tr><td>Copyright:</td>
116 <td>
117 <xsl:text>&#169;&#32;</xsl:text>
118 <xsl:apply-templates select="copyright/holder"/>
119 <xsl:text>&#32;</xsl:text>
120 <xsl:value-of select="date:year()"/>
121 </td>
122 </tr>
123 <tr><td>License:</td><td><xsl:apply-templates select="legalnotice"/></td></tr>
124 </table>
125 </xsl:template>
127 <xsl:template match="article/section/section/title" mode="heading">
128 <h2><xsl:apply-templates select="." mode="numbered-level-one"/></h2>
129 </xsl:template>
131 <xsl:template match="article/section/section/section/title">
132 <xsl:variable name="id">
133 <xsl:call-template name="normalizepath">
134 <xsl:with-param name="title" select="."/>
135 </xsl:call-template>
136 </xsl:variable>
137 <xsl:call-template name="whitespace-newline"/>
138 <xsl:call-template name="whitespace-newline"/>
139 <h3 id="{$id}"><xsl:apply-templates select="." mode="numbered-level-two"/></h3>
140 </xsl:template>
142 <xsl:template match="title" mode="numbered-level-one">
143 <xsl:number
144 count="/article/section/section[ancestor::*]"
145 from="/article/section"
146 level="multiple"
147 format="1. "
149 <xsl:value-of select="text()"/>
150 </xsl:template>
152 <xsl:template match="title" mode="numbered-level-two">
153 <xsl:number
154 count="article/section/section|article/section/section/section"
155 level="multiple"
156 format="1 "
158 <xsl:value-of select="text()"/>
159 </xsl:template>
161 <xsl:template match="article/section/section/section/section/title">
162 <xsl:variable name="id">
163 <xsl:call-template name="normalizepath">
164 <xsl:with-param name="title" select="."/>
165 </xsl:call-template>
166 </xsl:variable>
167 <h4><xsl:value-of select="."/><a name="{$id}">&#160;</a></h4>
168 </xsl:template>
170 <xsl:template match="article/section/section/section">
171 <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
172 </xsl:template>
174 <xsl:template match="article/section/section/section/section">
175 <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
176 </xsl:template>
178 <xsl:template match="para">
179 <p><xsl:apply-templates select="text()|code|ulink|emphasis"/></p>
180 </xsl:template>
182 <xsl:template match="emphasis">
183 <strong><xsl:apply-templates select="text()"/></strong>
184 </xsl:template>
186 <xsl:template match="ulink">
187 <xsl:if test="starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/')">
188 <xsl:variable name="pageid">
189 <xsl:call-template name="normalizepath">
190 <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])"/>
191 </xsl:call-template>
192 </xsl:variable>
193 <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>
194 </xsl:if>
195 <xsl:if test="not(starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'))">
196 <a href="{@url}"><xsl:value-of select="."/></a>
197 </xsl:if>
198 </xsl:template>
200 <xsl:template match="para/code">
201 <xsl:if test="contains (text(), '&#x0a;')">
202 <pre><xsl:value-of select="text()"/></pre>
203 </xsl:if>
204 <xsl:if test="not (contains (text(), '&#x0a;'))">
205 <code><xsl:value-of select="text()"/></code>
206 </xsl:if>
207 </xsl:template>
209 <xsl:template match="screen">
210 <pre><xsl:value-of select="text()"/></pre>
211 </xsl:template>
213 <!-- program listing -->
214 <xsl:template match="programlisting">
215 <pre class="o-box c-program"><xsl:apply-templates select="text()|type|methodname|token|phrase|lineannotation"/></pre>
216 </xsl:template>
218 <xsl:template match="type">
219 <span class="c-program-type"><xsl:value-of select="."/></span>
220 </xsl:template>
222 <xsl:template match="token">
223 <span class="c-program-token"><xsl:value-of select="."/></span>
224 </xsl:template>
226 <xsl:template match="methodname">
227 <span class="c-program-methodname"><xsl:value-of select="."/></span>
228 </xsl:template>
230 <xsl:template match="lineannotation">
231 <span class="c-program-comment"><xsl:value-of select="."/></span>
232 </xsl:template>
234 <xsl:template match="phrase">
235 <span class="c-program-phrase"><xsl:value-of select="."/></span>
236 </xsl:template>
238 <xsl:template match="programlisting/text()[. = '&#10;'][preceding-sibling::*[1][self::phrase]]">
239 <span class="c-program-phrase"><xsl:text>\n</xsl:text></span>
240 </xsl:template>
242 <xsl:template match="programlisting/text()[. = '&#10;&#10;'][preceding-sibling::*[1][self::phrase]]">
243 <span class="c-program-phrase"><xsl:text>\n\n</xsl:text></span>
244 </xsl:template>
246 <!-- lists -->
247 <xsl:template match="itemizedlist[listitem[not(@override)]]">
248 <ul><xsl:apply-templates select="listitem"/></ul>
249 </xsl:template>
251 <xsl:template match="listitem[not(@override)]">
252 <li><xsl:apply-templates select="para"/></li>
253 </xsl:template>
255 <xsl:template match="itemizedlist[listitem[@override='none']]">
256 <blockquote class="o-box c-rules"><xsl:apply-templates select="listitem"/></blockquote>
257 </xsl:template>
259 <xsl:template match="listitem[@override='none']/itemizedlist"><xsl:apply-templates select="listitem"/><xsl:text>
260 </xsl:text></xsl:template>
262 <xsl:template match="listitem[@override='none']">
263 <xsl:apply-templates select="para|itemizedlist"/>
264 </xsl:template>
266 <xsl:template match="listitem[@override='none']/para"><xsl:apply-templates select="text()|emphasis"/><xsl:text>
267 </xsl:text></xsl:template>
269 <xsl:template match="listitem[@override='none']/para/text()">
270 <xsl:if test="position()=1 and starts-with(.,' ')">
271 <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="substring-after(.,' ')"/></xsl:if>
272 </xsl:if>
273 <xsl:if test="position()!=1 or not(starts-with(.,' '))">
274 <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="."/></xsl:if>
275 </xsl:if>
276 </xsl:template>
278 <xsl:template match="listitem[@override='none']/para/emphasis[@role='strong']"><span class="literal"><xsl:value-of select="."/></span></xsl:template>
279 <xsl:template match="listitem[@override='none']/itemizedlist/listitem[@override='none']/para"><xsl:text>&#x09;</xsl:text><xsl:apply-templates select="text()|emphasis"/><xsl:text>
280 </xsl:text></xsl:template>
282 <!-- tables -->
283 <xsl:template match="informaltable">
284 <table class="c-informaltable">
285 <xsl:apply-templates select="tgroup/tbody/row"/>
286 </table>
287 </xsl:template>
289 <xsl:template match="row">
290 <tr>
291 <xsl:apply-templates select="entry"/>
292 </tr>
293 </xsl:template>
295 <xsl:template match="entry">
296 <td xsl:use-attribute-sets="entry-attrs">
297 <xsl:apply-templates select="para"/>
298 </td>
299 </xsl:template>
301 <xsl:attribute-set name="entry-attrs">
302 <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
303 <xsl:attribute name="colspan">
304 <xsl:if test="@nameend"><xsl:value-of select="number(substring-after(@nameend, 'col_'))+1"/></xsl:if>
305 </xsl:attribute>
306 </xsl:attribute-set>
308 </xsl:stylesheet>