source: trunk/SRC/Documentation/xmldoc/saxo_tracwiki.xsl @ 376

Last change on this file since 376 was 376, checked in by pinsard, 16 years ago

improve wiki FAQ production

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