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

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

correction for wiki links

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