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

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

some improvements in wiki production

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