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

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

some improvements in wiki production (hyperlinks)

  • Property snv:keywords set to Id
File size: 11.5 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:text>=== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ===</xsl:text>
67 <xsl:text>&#xA;</xsl:text>
68</xsl:template>
69
70<xsl:template match="d:sect3/d:title">
71 <xsl:text>&#xA;</xsl:text>
72 <xsl:text>==== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ====</xsl:text>
73 <xsl:text>&#xA;</xsl:text>
74</xsl:template>
75
76<xsl:template match="d:sect4/d:title">
77 <xsl:text>&#xA;</xsl:text>
78 <xsl:text>===== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> =====</xsl:text>
79 <xsl:text>&#xA;</xsl:text>
80</xsl:template>
81
82<xsl:template match="d:sect5/title">
83 <xsl:text>&#xA;</xsl:text>
84 <xsl:text>====== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ======</xsl:text>
85 <xsl:text>&#xA;</xsl:text>
86</xsl:template>
87
88<xsl:template match="d:sect2/d:simplesect/d:title">
89 <xsl:text>&#xA;</xsl:text>
90 <xsl:text>==== </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text> ====</xsl:text>
91 <xsl:text>&#xA;</xsl:text>
92</xsl:template>
93
94<xsl:template match="d:systemitem">
95 <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
96</xsl:template>
97
98<xsl:template match="d:para/d:command">
99 <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
100</xsl:template>
101
102<xsl:template match="d:filename">
103 <xsl:choose>
104  <xsl:when test="local-name(..)='userinput'">
105   <xsl:value-of select="."/>
106  </xsl:when>
107  <xsl:otherwise>
108   <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
109  </xsl:otherwise>
110 </xsl:choose>
111</xsl:template>
112
113<xsl:template match="d:varname">
114 <xsl:text>{{{</xsl:text><xsl:value-of select="."/><xsl:text>}}}</xsl:text>
115</xsl:template>
116
117<xsl:template match="d:literallayout">
118 <xsl:text>{{{</xsl:text><xsl:apply-templates/><xsl:text>}}}</xsl:text>
119</xsl:template>
120
121<xsl:template match="d:screen">
122 <!--
123we open an HTML block because it is not possible to have font effect (bold, italic)
124using TracWiki
125 -->
126 <xsl:text>&#xA;</xsl:text>
127 <xsl:text>{{{</xsl:text>
128 <xsl:text>&#xA;</xsl:text>
129 <xsl:text>#!html</xsl:text>
130 <xsl:text>&#xA;</xsl:text>
131 <pre class="screen">
132 <xsl:apply-templates/>
133 </pre>
134 <xsl:text>&#xA;</xsl:text>
135 <xsl:text>}}}</xsl:text>
136 <xsl:text>&#xA;</xsl:text>
137</xsl:template>
138
139<xsl:template match="d:screen/d:prompt">
140<code class="prompt"><xsl:value-of select="."/></code>
141</xsl:template>
142
143<xsl:template match="d:screen/d:userinput">
144<strong class="userinput"><code><xsl:apply-templates/></code></strong>
145</xsl:template>
146
147<xsl:template match="d:screen/d:userinput/d:command">
148<span><strong class="command"><xsl:value-of select="."/></strong></span>
149</xsl:template>
150
151<xsl:template match="d:screen/d:userinput/d:option">
152<code class="option"><xsl:value-of select="."/></code>
153</xsl:template>
154
155<xsl:template match="d:screen/d:computeroutput">
156<code class="computeroutput"><xsl:value-of select="."/></code>
157</xsl:template>
158
159<xsl:template match="d:screen/d:userinput/d:parameter">
160<em class="parameter"><code><xsl:apply-templates/></code></em>
161</xsl:template>
162
163<xsl:template match="d:blockquote">
164  <xsl:text>  </xsl:text><xsl:apply-templates/>
165</xsl:template>
166
167<xsl:template match="d:itemizedlist/d:listitem/d:simpara/d:link[@xl:href]">
168 <xsl:text>&#xA;</xsl:text>
169 <xsl:text> [</xsl:text><xsl:value-of select="@xl:href"/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
170</xsl:template>
171
172<xsl:template match="d:variablelist/">
173 <xsl:text>&#xA;</xsl:text>
174 <xsl:apply-templates/>
175</xsl:template>
176
177<xsl:template match="d:variablelist/d:varlistentry/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:quote">
183  <xsl:text>"</xsl:text><xsl:value-of select="."/><xsl:text>"</xsl:text>
184</xsl:template>
185
186<xsl:template match="d:itemizedlist/d:listitem">
187 <xsl:text>&#xA;</xsl:text>
188 <xsl:text> @star@ </xsl:text><xsl:apply-templates/>
189</xsl:template>
190
191<xsl:template match="d:imagedata[@fileref]">
192<!--
193ex : [[Image(source:/trunk/SRC/Documentation/xmldoc/images/showfig.png)]]
194-->
195<xsl:text>[[Image(source:/trunk/SRC/Documentation/xmldoc/</xsl:text><xsl:value-of select="@fileref"/><xsl:text>)]]</xsl:text>
196</xsl:template>
197
198<xsl:template match="d:link[@xl:href]">
199<xsl:variable name="link">
200 <xsl:choose>
201  <xsl:when test="contains(@xl:href,'firststeps.html')">
202   <xsl:text>wiki:FirstSteps</xsl:text>
203  </xsl:when>
204  <xsl:when test="contains(@xl:href,'all_plots.html')">
205   <xsl:text>wiki:AllPlots</xsl:text>
206  </xsl:when>
207  <xsl:when test="contains(@xl:href,'faqsaxo.html')">
208   <xsl:text>wiki:FaqSaxo</xsl:text>
209  </xsl:when>
210  <xsl:when test="contains(@xl:href,'getsaxo.html')">
211   <xsl:text>wiki:GetSaxo</xsl:text>
212  </xsl:when>
213  <xsl:when test="contains(@xl:href,'infoupdatecm.html')">
214   <xsl:text>wiki:InfoUpdateCm</xsl:text>
215  </xsl:when>
216  <xsl:when test="contains(@xl:href,'infoupdatekwd.html')">
217   <xsl:text>wiki:InfoUpdateKwd</xsl:text>
218  </xsl:when>
219  <xsl:when test="contains(@xl:href,'mailing.html')">
220   <xsl:text>wiki:Mailing</xsl:text>
221  </xsl:when>
222  <xsl:when test="contains(@xl:href,'mini_notice.html')">
223   <xsl:text>wiki:MiniNotice</xsl:text>
224  </xsl:when>
225  <xsl:when test="contains(@xl:href,'tiplink.html')">
226   <xsl:text>wiki:TipLink</xsl:text>
227  </xsl:when>
228  <xsl:when test="contains(@xl:href,'updatesaxo.html')">
229   <xsl:text>wiki:UpdateSaxo</xsl:text>
230  </xsl:when>
231  <xsl:when test="contains(@xl:href,'whatissaxo.html')">
232   <xsl:text>wiki:WhatisSaxo</xsl:text>
233  </xsl:when>
234  <xsl:when test="contains(@xl:href,'whatsnew.html')">
235   <xsl:text>wiki:WhatsNew</xsl:text>
236  </xsl:when>
237  <xsl:when test="contains(@xl:href,'websaxo.html')">
238   <xsl:text>wiki:WikiStart</xsl:text>
239  </xsl:when>
240  <xsl:when test="contains(@xl:href,'../../Tests/')">
241   <xsl:text>source:/trunk/SRC/Tests/</xsl:text><xsl:value-of select="substring-after(@xl:href,'../../Tests/')"/>
242  </xsl:when>
243  <xsl:when test="contains(@xl:href,'idldoc_html_output')">
244 <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/')"/>
245  </xsl:when>
246  <xsl:when test="contains(@xl:href,'idlfiles/')">
247 <xsl:text>source:/trunk/SRC/Documentation/xmldoc/idlfiles/</xsl:text><xsl:value-of select="substring-after(@xl:href,'idlfiles/')"/>
248  </xsl:when>
249  <xsl:when test="contains(@xl:href,'figpng/')">
250   <xsl:text>source:/trunk/SRC/Documentation/xmldoc/figpng/</xsl:text><xsl:value-of select="substring-after(@xl:href,'figpng/')"/>
251  </xsl:when>
252  <xsl:otherwise>
253   <xsl:value-of select="@xl:href"/>
254  </xsl:otherwise>
255 </xsl:choose>
256</xsl:variable>
257<xsl:text>[</xsl:text><xsl:value-of select="$link"/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
258</xsl:template>
259
260<xsl:template match="d:quote">
261  <xsl:text>"</xsl:text><xsl:value-of select="."/><xsl:text>"</xsl:text>
262</xsl:template>
263
264<xsl:template match="d:email">
265<xsl:text>[mailto:</xsl:text><xsl:value-of select="."/> <xsl:text> </xsl:text><xsl:value-of select="."/> <xsl:text>]</xsl:text>
266</xsl:template>
267
268<xsl:template match="d:variablelist/d:varlistentry/d:term">
269 <xsl:text>'''</xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>'''</xsl:text>
270</xsl:template>
271
272<xsl:template match="d:emphasis">
273  <xsl:text>''</xsl:text><xsl:value-of select="."/><xsl:text>''</xsl:text>
274</xsl:template>
275
276<xsl:template match="d:emphasis[@role='bold']">
277 <xsl:text>'''</xsl:text><xsl:value-of select="."/><xsl:text>'''</xsl:text>
278</xsl:template>
279
280
281<xsl:template match="d:replaceable">
282 <xsl:choose>
283  <xsl:when test="local-name(..)='userinput'">
284   <code class="replaceable"><xsl:value-of select="."/></code>
285  </xsl:when>
286  <xsl:when test="local-name(..)='parameter'">
287   <code class="replaceable"><xsl:value-of select="."/></code>
288  </xsl:when>
289  <xsl:otherwise>
290   <xsl:text>'''''</xsl:text><xsl:value-of select="."/><xsl:text>'''''</xsl:text>
291  </xsl:otherwise>
292 </xsl:choose>
293</xsl:template>
294
295<xsl:template match="d:superscript">
296  <xsl:text>^</xsl:text><xsl:value-of select="."/><xsl:text>^</xsl:text>
297</xsl:template>
298
299<xsl:template match="d:subscript">
300  <xsl:text>,,</xsl:text><xsl:value-of select="."/><xsl:text>,,</xsl:text>
301</xsl:template>
302
303<xsl:template match="d:simplelist">
304<!-- but beware of links inside -->
305 <xsl:text>&#xA;</xsl:text>
306 <xsl:text>{{{</xsl:text>
307 <xsl:text>&#xA;</xsl:text>
308 <xsl:text>#!docbook</xsl:text>
309 <xsl:text>&#xA;</xsl:text>
310 <xsl:copy-of select="."/>
311 <xsl:text>&#xA;</xsl:text>
312 <xsl:text>}}}</xsl:text>
313 <xsl:text>&#xA;</xsl:text>
314</xsl:template>
315
316<xsl:template match="d:informaltable">
317<!-- but beware of links inside -->
318 <xsl:text>&#xA;</xsl:text>
319 <xsl:text>{{{</xsl:text>
320 <xsl:text>&#xA;</xsl:text>
321 <xsl:text>#!docbook</xsl:text>
322 <xsl:text>&#xA;</xsl:text>
323 <xsl:copy-of select="."/>
324 <xsl:text>&#xA;</xsl:text>
325 <xsl:text>}}}</xsl:text>
326 <xsl:text>&#xA;</xsl:text>
327</xsl:template>
328
329<xsl:template match="d:xref"> 
330  <xsl:variable name="target" select="key('id',@linkend)[1]"/>
331  <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>
332</xsl:template>
333
334<!-- do not reproduce the followings elements -->
335<xsl:template match="d:mediaobject/d:textobject"/>
336<xsl:template match="d:info/d:authorgroup"/>
337<xsl:template match="d:info/d:revhistory"/>
338<xsl:template match="d:info/d:pubdate"/>
339<xsl:template match="d:keywordset"/>
340
341</xsl:stylesheet> 
Note: See TracBrowser for help on using the repository browser.