source: trunk/adm/guides/tracwiki.xsl @ 3

Last change on this file since 3 was 3, checked in by pinsard, 15 years ago

beginning of documentations : draft guides

  • Property svn:keywords set to Id
File size: 14.3 KB
Line 
1<?xml version='1.0' encoding='ISO-8859-1'?> 
2<xsl:stylesheet 
3xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4xmlns:xl="http://www.w3.org/1999/xlink"
5xmlns:d="http://docbook.org/ns/docbook"
6exclude-result-prefixes="d"
7version="1.0">
8<!--
9module :
10transformation docbook en un tracwiki
11
12original location :
13/usr/home/fplod/incas/amsu/amsu_ws/adm/guides/tracwiki.xsl sur aedon.locean-ipsl.upmc.fr
14
15must be followed by awk -f trackwiki.awk
16because I did not yet correctly handle "* text" (with no linefeed)
17
18update :
19$Id$
20fplod 2008-10-13T09:15:46Z aedon.locean-ipsl.upmc.fr (Darwin)
21creation from SAXO project
22cf http://forge.ipsl.jussieu.fr/superbib/wiki/WikiFormatting
23et http://www.sagehill.net/docbookxsl/CustomDb5Xsl.html
24car 1re xsl pour db5
25-->
26
27
28<!--
29xml output with no xml declaration : this is the only way to make xsl:copy-of copy
30nodes instead of contents of nodes
31-->
32<xsl:output method="xml" 
33indent="no" 
34omit-xml-declaration="yes"/>
35
36<xsl:strip-space elements="d:article d:sect1 d:sect2 d:sect3 d:sect4 d:variablellist d:itemizedlist d:listitem d:varlistentry d:term d:para d:simpara"/>
37
38<xsl:template match="/">
39 <xsl:apply-templates/>
40</xsl:template>
41
42<xsl:template match="d:article/d:title">
43<!-- pour ajouter une table des matières
44d'après
45http://groups.google.com/group/trac-users/browse_thread/thread/2c2cf9830c190a7d#e0a71ce3da67fb53
46-->
47 <xsl:text>= </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> =</xsl:text>
48 <xsl:text>&#xA;</xsl:text>
49 <xsl:text>[[PageOutline]]</xsl:text>
50 <xsl:text>&#xA;</xsl:text>
51</xsl:template>
52
53<xsl:template match="d:sect1/d:title">
54 <xsl:text>&#xA;</xsl:text>
55 <xsl:text>== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ==</xsl:text>
56 <xsl:text>&#xA;</xsl:text>
57</xsl:template>
58
59<xsl:template match="d:qandadiv/d:title">
60 <xsl:text>&#xA;</xsl:text>
61 <xsl:text>== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ==</xsl:text>
62 <xsl:text>&#xA;</xsl:text>
63</xsl:template>
64
65<xsl:template match="d:sect2/d:title">
66 <xsl:text>&#xA;</xsl:text>
67 <xsl:variable name="newtitle">
68  <xsl:call-template name="replace-string">
69   <xsl:with-param name="text" select="normalize-space(.)"/>
70   <xsl:with-param name="replace" select="'&gt;'"/>
71<!-- do not how to write > instead of &gt; ++. need sed features --> 
72   <xsl:with-param name="with" select="'&gt;'"/>
73  </xsl:call-template>
74 </xsl:variable>
75 <xsl:text>=== </xsl:text><xsl:value-of select="$newtitle"/><xsl:text> ===</xsl:text>
76 <xsl:text>&#xA;</xsl:text>
77</xsl:template>
78
79<xsl:template match="d:qandaentry/d:question/d:para">
80 <xsl:text>&#xA;</xsl:text>
81 <xsl:variable name="newtitle">
82  <xsl:call-template name="replace-string">
83   <xsl:with-param name="text" select="normalize-space(.)"/>
84   <xsl:with-param name="replace" select="'&gt;'"/>
85<!-- do not how to write > instead of &gt; ++. need sed features --> 
86   <xsl:with-param name="with" select="'&gt;'"/>
87  </xsl:call-template>
88 </xsl:variable>
89 <xsl:text>=== </xsl:text><xsl:value-of select="$newtitle"/><xsl:text> ===</xsl:text>
90 <xsl:text>&#xA;</xsl:text>
91</xsl:template>
92
93<xsl:template match="d:sect3/d:title">
94 <xsl:text>&#xA;</xsl:text>
95 <xsl:text>==== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ====</xsl:text>
96 <xsl:text>&#xA;</xsl:text>
97</xsl:template>
98
99<xsl:template match="d:sect4/d:title">
100 <xsl:text>&#xA;</xsl:text>
101 <xsl:text>===== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> =====</xsl:text>
102 <xsl:text>&#xA;</xsl:text>
103</xsl:template>
104
105<xsl:template match="d:sect5/title">
106 <xsl:text>&#xA;</xsl:text>
107 <xsl:text>====== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ======</xsl:text>
108 <xsl:text>&#xA;</xsl:text>
109</xsl:template>
110
111<xsl:template match="d:sect2/d:simplesect/d:title">
112 <xsl:text>&#xA;</xsl:text>
113 <xsl:text>==== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ====</xsl:text>
114 <xsl:text>&#xA;</xsl:text>
115</xsl:template>
116
117<xsl:template match="d:systemitem">
118 <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
119</xsl:template>
120
121<xsl:template match="d:para/d:command">
122 <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
123</xsl:template>
124
125<xsl:template match="d:filename">
126 <xsl:choose>
127  <xsl:when test="local-name(..)='userinput'">
128   <xsl:value-of select="."/>
129  </xsl:when>
130  <xsl:otherwise>
131   <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
132  </xsl:otherwise>
133 </xsl:choose>
134</xsl:template>
135
136<xsl:template match="d:varname">
137 <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
138</xsl:template>
139
140<xsl:template match="d:literallayout">
141 <xsl:text>{{{</xsl:text><xsl:apply-templates/><xsl:text>}}}</xsl:text>
142</xsl:template>
143<xsl:template match="d:literal">
144 <xsl:text>{{{</xsl:text><xsl:apply-templates/><xsl:text>}}}</xsl:text>
145</xsl:template>
146
147<xsl:template match="d:screen">
148 <!--
149we open an HTML block because it is not possible to have font effect (bold, italic) using TracWiki
150 -->
151 <xsl:text>&#xA;</xsl:text>
152 <xsl:text>{{{</xsl:text>
153 <xsl:text>&#xA;</xsl:text>
154 <xsl:text>#!html</xsl:text>
155 <xsl:text>&#xA;</xsl:text>
156 <pre class="screen">
157 <xsl:apply-templates/>
158 </pre>
159 <xsl:text>&#xA;</xsl:text>
160 <xsl:text>}}}</xsl:text>
161 <xsl:text>&#xA;</xsl:text>
162</xsl:template>
163
164<xsl:template match="d:programlisting">
165 <!--
166we open an HTML block because it is not possible to have font effect (bold, italic) using TracWiki
167 -->
168 <xsl:text>&#xA;</xsl:text>
169 <xsl:text>{{{</xsl:text>
170 <xsl:text>&#xA;</xsl:text>
171 <xsl:text>#!html</xsl:text>
172 <xsl:text>&#xA;</xsl:text>
173 <pre class="screen">
174 <xsl:apply-templates/>
175 </pre>
176 <xsl:text>&#xA;</xsl:text>
177 <xsl:text>}}}</xsl:text>
178 <xsl:text>&#xA;</xsl:text>
179</xsl:template>
180
181<xsl:template match="d:screen/d:prompt">
182<code class="prompt"><xsl:value-of select="."/></code>
183</xsl:template>
184
185<xsl:template match="d:screen/d:userinput">
186<strong class="userinput"><code><xsl:apply-templates/></code></strong>
187</xsl:template>
188
189<xsl:template match="d:screen/d:userinput/d:command">
190<span><strong class="command"><xsl:value-of select="."/></strong></span>
191</xsl:template>
192
193<xsl:template match="d:screen/d:userinput/d:option">
194<code class="option"><xsl:value-of select="."/></code>
195</xsl:template>
196
197<xsl:template match="d:screen/d:computeroutput">
198<code class="computeroutput"><xsl:value-of select="."/></code>
199</xsl:template>
200
201<xsl:template match="d:screen/d:userinput/d:parameter">
202<em class="parameter"><code><xsl:apply-templates/></code></em>
203</xsl:template>
204
205<xsl:template match="d:blockquote">
206  <xsl:text>  </xsl:text><xsl:apply-templates/>
207</xsl:template>
208
209<xsl:template match="d:itemizedlist/d:listitem/d:simpara/d:link[@xl:href]">
210 <xsl:text>&#xA;</xsl:text>
211 <xsl:text> [</xsl:text><xsl:value-of select="@xl:href"/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
212</xsl:template>
213
214<xsl:template match="d:variablelist/">
215 <xsl:text>&#xA;</xsl:text>
216 <xsl:apply-templates/>
217</xsl:template>
218
219<xsl:template match="d:variablelist/d:varlistentry/d:listitem/d:simpara/d:link[@xl:href]">
220 <xsl:text>&#xA;</xsl:text>
221 <xsl:text> [</xsl:text><xsl:value-of select="@xl:href"/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
222</xsl:template>
223
224<xsl:template match="d:quote">
225  <xsl:text>"</xsl:text><xsl:value-of select="."/><xsl:text>"</xsl:text>
226</xsl:template>
227
228<xsl:template match="d:itemizedlist/d:listitem">
229 <xsl:text>&#xA;</xsl:text>
230 <xsl:text> @star@ </xsl:text><xsl:apply-templates/>
231</xsl:template>
232
233<xsl:template match="d:imagedata[@fileref]">
234<!--
235ex : [[Image(source:/trunk/SRC/Documentation/xmldoc/images/showfig.png)]]
236-->
237<xsl:text>[[Image(source:/trunk/SRC/Documentation/xmldoc/</xsl:text><xsl:value-of select="@fileref"/><xsl:text>)]]</xsl:text>
238</xsl:template>
239
240<xsl:template match="d:link[@xl:href]">
241<xsl:variable name="link">
242 <xsl:choose>
243  <xsl:when test="contains(@xl:href,'firststeps.html')">
244   <xsl:text>wiki:FirstSteps</xsl:text>
245  </xsl:when>
246  <xsl:when test="contains(@xl:href,'faq.html')">
247   <xsl:text>wiki:Faq</xsl:text>
248  </xsl:when>
249  <xsl:when test="contains(@xl:href,'get.html')">
250   <xsl:text>wiki:Get</xsl:text>
251  </xsl:when>
252  <xsl:when test="contains(@xl:href,'mailing.html')">
253   <xsl:text>wiki:Mailing</xsl:text>
254  </xsl:when>
255  <xsl:when test="contains(@xl:href,'tiplink.html')">
256   <xsl:text>wiki:TipLink</xsl:text>
257  </xsl:when>
258  <xsl:when test="contains(@xl:href,'update.html')">
259   <xsl:text>wiki:Update</xsl:text>
260  </xsl:when>
261  <xsl:when test="contains(@xl:href,'whatis.html')">
262   <xsl:text>wiki:Whatis</xsl:text>
263  </xsl:when>
264  <xsl:when test="contains(@xl:href,'whatsnew.html')">
265   <xsl:text>wiki:WhatsNew</xsl:text>
266  </xsl:when>
267  <xsl:when test="contains(@xl:href,'index.html')">
268   <xsl:text>wiki:WikiStart</xsl:text>
269  </xsl:when>
270  <xsl:when test="contains(@xl:href,'../../')">
271   <xsl:text>source:/trunk/SRC/</xsl:text><xsl:value-of select="substring-after(@xl:href,'../../')"/>
272  </xsl:when>
273  <xsl:when test="contains(@xl:href,'figpng/')">
274   <xsl:text>source:/trunk/SRC/Documentation/xmldoc/figpng/</xsl:text><xsl:value-of select="substring-after(@xl:href,'figpng/')"/>
275  </xsl:when>
276  <xsl:otherwise>
277   <xsl:value-of select="@xl:href"/>
278  </xsl:otherwise>
279 </xsl:choose>
280</xsl:variable>
281<xsl:text>[</xsl:text><xsl:value-of select="$link"/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
282</xsl:template>
283
284<xsl:template match="d:quote">
285  <xsl:text>"</xsl:text><xsl:value-of select="."/><xsl:text>"</xsl:text>
286</xsl:template>
287
288<xsl:template match="d:email">
289<xsl:text>[mailto:</xsl:text><xsl:value-of select="."/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
290</xsl:template>
291
292<xsl:template match="d:variablelist/d:varlistentry/d:term">
293 <xsl:text>'''</xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>'''</xsl:text>
294</xsl:template>
295
296<xsl:template match="d:emphasis">
297  <xsl:text>''</xsl:text><xsl:value-of select="."/><xsl:text>''</xsl:text>
298</xsl:template>
299
300<xsl:template match="d:emphasis[@role='bold']">
301 <xsl:text>'''</xsl:text><xsl:value-of select="."/><xsl:text>'''</xsl:text>
302</xsl:template>
303
304<xsl:template match="d:caution">
305 <xsl:text>&#xA;</xsl:text>
306 <xsl:text>&#xA;</xsl:text>
307 <xsl:text>'''Caution'''</xsl:text>
308 <xsl:text>&#xA;</xsl:text>
309 <xsl:text>&#xA;</xsl:text>
310 <xsl:apply-templates/>
311</xsl:template>
312
313<xsl:template match="d:note">
314 <xsl:text>&#xA;</xsl:text>
315 <xsl:text>&#xA;</xsl:text>
316 <xsl:text>'''Note'''</xsl:text>
317 <xsl:text>&#xA;</xsl:text>
318 <xsl:text>&#xA;</xsl:text>
319 <xsl:apply-templates/>
320</xsl:template>
321
322<xsl:template match="d:replaceable">
323 <xsl:choose>
324  <xsl:when test="local-name(..)='userinput'">
325   <code class="replaceable"><xsl:value-of select="."/></code>
326  </xsl:when>
327  <xsl:when test="local-name(..)='parameter'">
328   <code class="replaceable"><xsl:value-of select="."/></code>
329  </xsl:when>
330  <xsl:otherwise>
331   <xsl:text>'''''</xsl:text><xsl:value-of select="."/><xsl:text>'''''</xsl:text>
332  </xsl:otherwise>
333 </xsl:choose>
334</xsl:template>
335
336<xsl:template match="d:superscript">
337  <xsl:text>^</xsl:text><xsl:value-of select="."/><xsl:text>^</xsl:text>
338</xsl:template>
339
340<xsl:template match="d:subscript">
341  <xsl:text>,,</xsl:text><xsl:value-of select="."/><xsl:text>,,</xsl:text>
342</xsl:template>
343
344<xsl:template match="d:simplelist">
345<!-- but beware of links inside -->
346 <xsl:text>&#xA;</xsl:text>
347 <xsl:text>{{{</xsl:text>
348 <xsl:text>&#xA;</xsl:text>
349 <xsl:text>#!docbook</xsl:text>
350 <xsl:text>&#xA;</xsl:text>
351 <xsl:copy-of select="."/>
352 <xsl:text>&#xA;</xsl:text>
353 <xsl:text>}}}</xsl:text>
354 <xsl:text>&#xA;</xsl:text>
355</xsl:template>
356
357<xsl:template match="d:informaltable">
358<!-- but beware of links inside -->
359 <xsl:text>&#xA;</xsl:text>
360 <xsl:text>{{{</xsl:text>
361 <xsl:text>&#xA;</xsl:text>
362 <xsl:text>#!docbook</xsl:text>
363 <xsl:text>&#xA;</xsl:text>
364 <xsl:copy-of select="."/>
365 <xsl:text>&#xA;</xsl:text>
366 <xsl:text>}}}</xsl:text>
367 <xsl:text>&#xA;</xsl:text>
368</xsl:template>
369
370<!-- ++ pb when in listitem/para
371<xsl:template match="d:menuchoice|d:guimenu|d:guisubmenu">
372 <xsl:text>&#xA;</xsl:text>
373 <xsl:text>{{{</xsl:text>
374 <xsl:text>&#xA;</xsl:text>
375 <xsl:text>#!docbook</xsl:text>
376 <xsl:text>&#xA;</xsl:text>
377 <xsl:copy-of select="."/>
378 <xsl:text>&#xA;</xsl:text>
379 <xsl:text>}}}</xsl:text>
380 <xsl:text>&#xA;</xsl:text>
381</xsl:template>
382-->
383
384<xsl:template match="d:informaltable">
385<!-- but beware of links inside -->
386 <xsl:text>&#xA;</xsl:text>
387 <xsl:text>{{{</xsl:text>
388 <xsl:text>&#xA;</xsl:text>
389 <xsl:text>#!docbook</xsl:text>
390 <xsl:text>&#xA;</xsl:text>
391 <xsl:copy-of select="."/>
392 <xsl:text>&#xA;</xsl:text>
393 <xsl:text>}}}</xsl:text>
394 <xsl:text>&#xA;</xsl:text>
395</xsl:template>
396
397<xsl:template match="d:link[@linkend]"> 
398 <xsl:variable name="target" select="key('id',@linkend)[1]"/>
399 <xsl:text>[#</xsl:text><xsl:value-of select="translate(normalize-space(//*[normalize-space(@xml:id='$target')]/d:title),' ','')"/><xsl:text>]</xsl:text>
400</xsl:template>
401
402<xsl:template match="d:xref"> 
403  <xsl:variable name="target" select="key('id',@linkend)[1]"/>
404  <xsl:text>[#</xsl:text><xsl:value-of select="translate(normalize-space(//d:sect1[normalize-space(@xml:id='$target')]/d:title),' ','')"/><xsl:text> </xsl:text> <xsl:value-of select="normalize-space(//d:sect1[normalize-space(@xml:id='$target')]/d:title)"/><xsl:text>]</xsl:text>
405</xsl:template>
406
407<xsl:template match="d:callout"> 
408 <xsl:text>[[Image(source:/trunk/SRC/Documentation/xmldoc/images/callouts/</xsl:text><xsl:value-of select="position() div 2"/><xsl:text>.png)]]</xsl:text><xsl:apply-templates/>
409</xsl:template>
410
411<xsl:template name="replace-string">
412<!-- from http://www.dpawson.co.uk/xsl/sect2/replace.html -->
413    <xsl:param name="text"/>
414    <xsl:param name="replace"/>
415    <xsl:param name="with"/>
416    <xsl:choose>
417      <xsl:when test="contains($text,$replace)">
418        <xsl:value-of select="substring-before($text,$replace)"/>
419        <xsl:value-of select="$with"/>
420        <xsl:call-template name="replace-string">
421          <xsl:with-param name="text"
422select="substring-after($text,$replace)"/>
423          <xsl:with-param name="replace" select="$replace"/>
424          <xsl:with-param name="with" select="$with"/>
425        </xsl:call-template>
426      </xsl:when>
427      <xsl:otherwise>
428        <xsl:value-of select="$text"/>
429      </xsl:otherwise>
430    </xsl:choose>
431  </xsl:template>
432
433<!-- do not reproduce the followings elements -->
434<xsl:template match="d:mediaobject/d:textobject"/>
435<xsl:template match="d:info/d:authorgroup"/>
436<xsl:template match="d:info/d:revhistory"/>
437<xsl:template match="d:info/d:pubdate"/>
438<xsl:template match="d:keywordset"/>
439
440</xsl:stylesheet> 
Note: See TracBrowser for help on using the repository browser.