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

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

correction for wiki links

  • Property snv:keywords set to Id
File size: 14.7 KB
RevLine 
[351]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<!--
[411]9
10module
11======
12
[351]13transformation docbook en un tracwiki
14
[411]15CAUTIONS
16========
[351]17
[411]18must be followed by :
19 awk -f saxo_trackwiki.awk
20
[351]21because I did not yet correctly handle "* text" (with no linefeed)
[376]22
[411]23
24and
25
26 sed -f linkwiki.sed
27
28TODO
29====
30
[351]31++ voir http://trac-hacks.org/wiki/XsltMacro
[411]32
[376]33++ add menu tags menuchoice, gui*, shortcut, keycombo, etc.
[411]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
[376]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
[351]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
[352]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
[351]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>
[352]87 <xsl:text>&#xA;</xsl:text>
[351]88</xsl:template>
89
90<xsl:template match="d:sect1/d:title">
[352]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>
[351]94</xsl:template>
95
[376]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
[351]102<xsl:template match="d:sect2/d:title">
[352]103 <xsl:text>&#xA;</xsl:text>
[356]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>
[352]113 <xsl:text>&#xA;</xsl:text>
[351]114</xsl:template>
115
[376]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
[351]130<xsl:template match="d:sect3/d:title">
[352]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>
[351]134</xsl:template>
135
136<xsl:template match="d:sect4/d:title">
[352]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>
[351]140</xsl:template>
141
142<xsl:template match="d:sect5/title">
[352]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>
[351]146</xsl:template>
147
148<xsl:template match="d:sect2/d:simplesect/d:title">
[352]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>
[351]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">
[354]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>
[351]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>
[356]180<xsl:template match="d:literal">
181 <xsl:text>{{{</xsl:text><xsl:apply-templates/><xsl:text>}}}</xsl:text>
182</xsl:template>
[351]183
184<xsl:template match="d:screen">
185 <!--
[356]186we open an HTML block because it is not possible to have font effect (bold, italic) using TracWiki
[351]187 -->
[354]188 <xsl:text>&#xA;</xsl:text>
[351]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>
[352]198 <xsl:text>&#xA;</xsl:text>
[351]199</xsl:template>
200
[376]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
[351]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]">
[354]247 <xsl:text>&#xA;</xsl:text>
[411]248 <xsl:text> [</xsl:text><xsl:value-of select="@xl:href"/> <xsl:text>AAA </xsl:text><xsl:value-of select="."/><xsl:text>]</xsl:text>
[351]249</xsl:template>
250
[354]251<xsl:template match="d:variablelist/">
252 <xsl:text>&#xA;</xsl:text>
253 <xsl:apply-templates/>
254</xsl:template>
255
[352]256<xsl:template match="d:variablelist/d:varlistentry/d:listitem/d:simpara/d:link[@xl:href]">
[354]257 <xsl:text>&#xA;</xsl:text>
[411]258 <xsl:text> [</xsl:text><xsl:value-of select="@xl:href"/> <xsl:text>BBB </xsl:text><xsl:value-of select="."/><xsl:text>]</xsl:text>
[352]259</xsl:template>
260
[351]261<xsl:template match="d:quote">
262  <xsl:text>"</xsl:text><xsl:value-of select="."/><xsl:text>"</xsl:text>
263</xsl:template>
264
[352]265<xsl:template match="d:itemizedlist/d:listitem">
[353]266 <xsl:text>&#xA;</xsl:text>
[351]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
[355]277<xsl:template match="d:link[@xl:href]">
278<xsl:variable name="link">
[411]279  <xsl:choose>
[356]280  <xsl:when test="contains(@xl:href,'../../')">
281   <xsl:text>source:/trunk/SRC/</xsl:text><xsl:value-of select="substring-after(@xl:href,'../../')"/>
[355]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>
[351]292  <xsl:otherwise>
293   <xsl:value-of select="@xl:href"/>
294  </xsl:otherwise>
295 </xsl:choose>
296</xsl:variable>
[355]297<xsl:text>[</xsl:text><xsl:value-of select="$link"/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
[351]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">
[411]305<xsl:text>[mailto:</xsl:text><xsl:value-of select="."/> <xsl:text>DDD </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
[351]306</xsl:template>
307
308<xsl:template match="d:variablelist/d:varlistentry/d:term">
[352]309 <xsl:text>'''</xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>'''</xsl:text>
[351]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
[354]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
[356]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>
[354]328
[356]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
[351]338<xsl:template match="d:replaceable">
[355]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>
[351]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 -->
[354]362 <xsl:text>&#xA;</xsl:text>
[351]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>
[352]370 <xsl:text>&#xA;</xsl:text>
[351]371</xsl:template>
372
373<xsl:template match="d:informaltable">
374<!-- but beware of links inside -->
[354]375 <xsl:text>&#xA;</xsl:text>
[351]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>
[352]383 <xsl:text>&#xA;</xsl:text>
[351]384</xsl:template>
385
[376]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
[356]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
[351]418<xsl:template match="d:xref"> 
419  <xsl:variable name="target" select="key('id',@linkend)[1]"/>
[355]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>
[351]421</xsl:template>
422
[356]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
[351]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.