Another round of fixes (projdoc -> howto) for images
[Samba/gebeck_regimport.git] / docs / xslt / expand-sambadoc.xsl
blob217f621f80c10a3ee3db6ca0294c790974dfc950
1 <?xml version='1.0'?>
2 <!--
3 Samba-documentation specific stylesheets
4 Published under the GNU GPL
6 (C) Jelmer Vernooij 2002-2004
7 (C) Alexander Bokovoy 2002-2004
8 -->
9 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:exsl="http://exslt.org/common"
11 xmlns:samba="http://samba.org/common"
12 version="1.1"
13 extension-element-prefixes="exsl">
15 <xsl:import href="../settings.xsl"/>
17 <xsl:output method="xml"/>
19 <xsl:param name="xmlSambaNsUri" select="'http://samba.org/common'"/>
21 <xsl:template match="reference/refentry/refsect1">
22 <xsl:if test="title!='VERSION' and title!='AUTHOR'">
23 <xsl:element name="refsect1">
24 <xsl:if test="@id!=''">
25 <xsl:attribute name="id">
26 <xsl:value-of select="@id"/>
27 </xsl:attribute>
28 </xsl:if>
29 <xsl:apply-templates/>
30 </xsl:element>
31 </xsl:if>
32 </xsl:template>
34 <xsl:template match="translator">
35 <xsl:element name="othercredit">
36 <xsl:element name="author">
37 <xsl:apply-templates/>
38 <xsl:element name="contrib">
39 <xsl:text>Translation to </xsl:text><xsl:value-of select="@lang"/>
40 </xsl:element>
41 </xsl:element>
42 </xsl:element>
43 </xsl:template>
45 <xsl:template match="reference/refentry">
46 <xsl:element name="section">
47 <xsl:attribute name="id">
48 <xsl:value-of select="@id"/>
49 </xsl:attribute>
50 <xsl:element name="title">
51 <xsl:value-of select="refmeta/refentrytitle"/>
52 <!-- <xsl:text> (</xsl:text>
53 <xsl:value-of select="refnamediv/refpurpose"/>
54 <xsl:text>)</xsl:text>-->
55 </xsl:element>
56 <xsl:apply-templates/>
57 </xsl:element>
58 </xsl:template>
60 <xsl:template match="reference/refentry/refmeta"/>
62 <xsl:template match="reference/refentry/refnamediv"/>
64 <xsl:template match="reference">
65 <xsl:element name="appendix">
66 <xsl:attribute name="id">
67 <xsl:value-of select="@id"/>
68 </xsl:attribute>
69 <xsl:apply-templates/>
70 </xsl:element>
71 </xsl:template>
73 <xsl:template match="/node()">
74 <xsl:text disable-output-escaping="yes">
75 &lt;!DOCTYPE </xsl:text><xsl:value-of select="name(.)"/><xsl:text disable-output-escaping="yes"> PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
76 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
78 &lt;!ENTITY % globalentities SYSTEM 'entities/global.entities'> %globalentities;
80 </xsl:text>
81 <xsl:copy>
82 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
83 <xsl:apply-templates/>
84 </xsl:copy>
85 </xsl:template>
88 <!-- This is needed to copy content unchanged -->
89 <xsl:template match="@*|node()">
91 <xsl:copy>
92 <xsl:apply-templates select="@*|node()"/>
93 </xsl:copy>
94 </xsl:template>
96 <xsl:template match="smbconfexample/smbconfoption|smbconfblock/smbconfoption">
98 <xsl:element name="member">
99 <xsl:element name="indexterm">
100 <xsl:element name="primary">
101 <xsl:value-of select="name"/>
102 </xsl:element>
103 </xsl:element>
104 <xsl:element name="parameter">
105 <xsl:text disable-output-escaping="yes">
106 &lt;?latex \hspace{1cm} ?&gt;
107 </xsl:text>
108 <xsl:value-of select="name"/>
109 <xsl:choose>
110 <xsl:when test="value != ''">
111 <xsl:text> = </xsl:text>
112 <xsl:value-of select="value"/>
113 </xsl:when>
114 </xsl:choose>
115 </xsl:element>
116 </xsl:element>
117 </xsl:template>
119 <xsl:template match="smbconfexample/smbconfcomment|smbconfblock/smbconfcomment">
120 <xsl:text disable-output-escaping="yes">
121 &lt;?latex \hspace{1cm} ?&gt;
122 </xsl:text>
123 <xsl:element name="member">
124 <xsl:text># </xsl:text>
125 <xsl:apply-templates/>
126 </xsl:element>
127 </xsl:template>
129 <xsl:template match="smbconfexample/smbconfsection|smbconfblock/smbconfsection">
130 <xsl:element name="member">
131 <xsl:text> </xsl:text>
132 </xsl:element>
133 <xsl:element name="member">
134 <xsl:element name="parameter">
135 <xsl:apply-templates/>
136 </xsl:element>
137 </xsl:element>
138 </xsl:template>
140 <xsl:template match="smbconfoption">
141 <!-- Include an index term -->
142 <xsl:element name="indexterm">
143 <xsl:element name="primary">
144 <xsl:value-of select="name"/>
145 </xsl:element>
146 </xsl:element>
148 <xsl:variable name="linkcontent">
149 <xsl:element name="parameter">
150 <xsl:attribute name="moreinfo">
151 <xsl:text>none</xsl:text>
152 </xsl:attribute>
153 <xsl:value-of select="name"/>
154 </xsl:element>
156 <xsl:choose>
157 <xsl:when test="value != ''">
158 <xsl:text> = </xsl:text>
159 <xsl:value-of select="value"/>
160 </xsl:when>
161 </xsl:choose>
162 </xsl:variable>
164 <xsl:choose>
165 <xsl:when test="$noreference = 1">
166 <xsl:value-of select="$linkcontent"/>
167 </xsl:when>
168 <xsl:otherwise>
169 <xsl:element name="link">
170 <xsl:attribute name="linkend">
171 <xsl:value-of select="translate(translate(string(name),' ',''),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
172 </xsl:attribute>
173 <xsl:value-of select="$linkcontent"/>
174 </xsl:element>
175 </xsl:otherwise>
176 </xsl:choose>
177 </xsl:template>
179 <!-- FIXME: Needs extension sometime -->
180 <xsl:template match="ntgroup|ntuser">
181 <xsl:element name="emphasis">
182 <xsl:apply-templates/>
183 </xsl:element>
184 </xsl:template>
186 <xsl:template match="smbconfexample">
187 <xsl:choose>
188 <xsl:when test="title = ''">
189 <xsl:message>
190 <xsl:text>Warning: smbconfexample does not have title!</xsl:text>
191 </xsl:message>
192 </xsl:when>
193 </xsl:choose>
194 <xsl:element name="example">
195 <xsl:choose>
196 <xsl:when test="@id != ''">
197 <xsl:attribute name="id">
198 <xsl:value-of select="@id"/>
199 </xsl:attribute>
200 </xsl:when>
201 </xsl:choose>
203 <xsl:element name="title">
204 <xsl:value-of select="title"/>
205 </xsl:element>
206 <xsl:element name="simplelist">
207 <xsl:apply-templates/>
208 </xsl:element>
209 </xsl:element>
210 </xsl:template>
212 <xsl:template match="smbconfexample/title">
213 </xsl:template>
215 <xsl:template match="smbconfblock">
216 <xsl:element name="simplelist">
217 <xsl:apply-templates/>
218 </xsl:element>
219 </xsl:template>
221 <xsl:template match="smbconfsection">
222 <xsl:element name="parameter">
223 <xsl:apply-templates/>
224 </xsl:element>
225 </xsl:template>
227 <xsl:template match="smbconfcomment">
228 <xsl:text># </xsl:text>
229 <xsl:apply-templates/>
230 </xsl:template>
232 <xsl:template match="smbfile">
233 <xsl:apply-templates/>
234 </xsl:template>
236 <xsl:template match="image">
237 <xsl:element name="figure">
238 <xsl:attribute name="id">
239 <xsl:choose>
240 <xsl:when test="@id != ''">
241 <xsl:value-of select="@id"/>
242 </xsl:when>
243 <xsl:otherwise>
244 <xsl:value-of select="imagefile"/>
245 </xsl:otherwise>
246 </xsl:choose>
247 </xsl:attribute>
249 <xsl:element name="title">
250 <xsl:value-of select="imagedescription"/>
251 </xsl:element>
252 <xsl:element name="mediaobject">
253 <xsl:element name="imageobject">
254 <xsl:attribute name="role"><xsl:text>latex</xsl:text></xsl:attribute>
255 <xsl:element name="imagedata">
256 <xsl:attribute name="fileref">
257 <xsl:text>howto/imagefiles/</xsl:text><xsl:value-of select="imagefile"/></xsl:attribute>
258 <xsl:attribute name="scale">
259 <xsl:choose>
260 <xsl:when test="@scale != ''">
261 <xsl:value-of select="@scale"/>
262 </xsl:when>
264 <xsl:otherwise>
265 <xsl:text>50</xsl:text>
266 </xsl:otherwise>
267 </xsl:choose>
268 </xsl:attribute>
269 <xsl:attribute name="scalefit"><xsl:text>1</xsl:text></xsl:attribute>
270 </xsl:element>
271 </xsl:element>
272 <xsl:element name="imageobject">
273 <xsl:element name="imagedata">
274 <xsl:attribute name="fileref">
275 <xsl:text>howto/imagefiles/</xsl:text><xsl:value-of select="imagefile"/><xsl:text>.png</xsl:text></xsl:attribute>
276 <xsl:attribute name="scale"><xsl:text>50</xsl:text></xsl:attribute>
277 <xsl:attribute name="scalefit"><xsl:text>1</xsl:text></xsl:attribute>
278 </xsl:element>
279 </xsl:element>
280 </xsl:element>
281 </xsl:element>
282 </xsl:template>
284 <xsl:template match="description"><xsl:apply-templates/></xsl:template>
286 <xsl:template match="value"><xsl:apply-templates/></xsl:template>
288 <xsl:template match="synonym"><xsl:apply-templates/></xsl:template>
290 <xsl:template match="related"><xsl:apply-templates/></xsl:template>
292 <xsl:template match="filterline">
293 <xsl:element name="programlisting">
294 <xsl:apply-templates/>
295 </xsl:element>
296 </xsl:template>
298 <xsl:template match="//samba:parameterlist">
299 <xsl:apply-templates>
300 <xsl:sort select="varlistentry/term/anchor"/>
301 </xsl:apply-templates>
302 </xsl:template>
304 <xsl:template match="value/comment">
305 <xsl:text>&#10;# </xsl:text>
306 <xsl:apply-templates/>
307 </xsl:template>
309 <xsl:template match="//samba:parameter">
310 <!-- reconstruct varlistentry - not all of them will go into separate files
311 and also we must repair the main varlistentry itself.
313 <xsl:variable name="cname"><xsl:value-of select="translate(translate(string(@name),' ',''),
314 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
315 </xsl:variable>
317 <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
319 <xsl:variable name="anchor">
320 <xsl:element name="anchor">
321 <xsl:attribute name="id">
322 <xsl:value-of select="$cname"/>
323 </xsl:attribute>
324 </xsl:element>
325 </xsl:variable>
327 <xsl:variable name="context">
328 <xsl:text> (</xsl:text>
329 <xsl:value-of select="@context"/>
330 <xsl:text>)</xsl:text>
331 </xsl:variable>
333 <xsl:variable name="term">
334 <xsl:element name="term">
335 <xsl:copy-of select="$anchor"/>
336 <xsl:value-of select="@name"/>
337 <xsl:value-of select="$context"/>
338 </xsl:element>
339 </xsl:variable>
342 <!-- Generate list of examples -->
343 <xsl:variable name="examples">
344 <xsl:for-each select="value">
345 <xsl:if test="@type = 'example'">
346 <xsl:element name="para">
347 <xsl:text>Example: </xsl:text>
348 <xsl:element name="emphasis">
349 <xsl:element name="parameter">
350 <xsl:copy-of select="$name"/>
351 </xsl:element>
352 <xsl:text> = </xsl:text>
353 <xsl:apply-templates select="."/>
354 <xsl:text>&#10;</xsl:text>
355 </xsl:element>
356 <xsl:text>&#10;</xsl:text>
357 </xsl:element>
358 </xsl:if>
359 </xsl:for-each>
360 </xsl:variable>
362 <xsl:variable name="tdefault">
363 <xsl:for-each select="value">
364 <xsl:if test="@type = 'default'">
365 <xsl:element name="para">
366 <xsl:text>Default: </xsl:text>
367 <xsl:element name="emphasis">
368 <xsl:element name="parameter">
369 <xsl:copy-of select="$name"/>
370 </xsl:element>
371 <xsl:text> = </xsl:text>
372 <xsl:apply-templates select="."/>
373 <xsl:text>&#10;</xsl:text>
374 </xsl:element>
375 <xsl:text>&#10;</xsl:text>
376 </xsl:element>
377 </xsl:if>
378 </xsl:for-each>
379 </xsl:variable>
381 <xsl:variable name="default">
382 <xsl:choose>
383 <xsl:when test="$tdefault = ''">
384 <xsl:element name="para">
385 <xsl:element name="emphasis">
386 <xsl:text>No default</xsl:text>
387 </xsl:element>
388 </xsl:element>
389 </xsl:when>
390 <xsl:otherwise>
391 <xsl:copy-of select="$tdefault"/>
392 </xsl:otherwise>
393 </xsl:choose>
394 </xsl:variable>
396 <xsl:variable name="content">
397 <xsl:apply-templates select="description"/>
398 </xsl:variable>
400 <xsl:for-each select="synonym">
401 <xsl:element name="varlistentry">
402 <xsl:text>&#10;</xsl:text>
403 <xsl:element name="indexterm">
404 <xsl:attribute name="significance">
405 <xsl:text>preferred</xsl:text>
406 </xsl:attribute>
407 <xsl:element name="primary">
408 <xsl:value-of select="."/>
409 </xsl:element>
410 <xsl:element name="see">
411 <xsl:value-of select="$name"/>
412 </xsl:element>
413 </xsl:element>
415 <xsl:element name="term">
416 <xsl:element name="anchor">
417 <xsl:attribute name="id">
418 <xsl:value-of select="translate(translate(string(.),' ',''), 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
419 </xsl:attribute>
420 </xsl:element>
421 <xsl:value-of select="."/>
422 </xsl:element>
424 <xsl:element name="listitem">
425 <xsl:element name="para"><xsl:text>This parameter is a synonym for </xsl:text><xsl:copy-of select="$name"/><xsl:text>.</xsl:text></xsl:element>
426 </xsl:element>
427 </xsl:element>
428 </xsl:for-each>
430 <xsl:element name="varlistentry">
431 <xsl:text>&#10;</xsl:text>
432 <xsl:element name="indexterm">
433 <xsl:attribute name="significance">
434 <xsl:text>preferred</xsl:text>
435 </xsl:attribute>
436 <xsl:element name="primary">
437 <xsl:value-of select="@name"/>
438 </xsl:element>
439 </xsl:element>
440 <xsl:copy-of select="$term"/>
441 <xsl:element name="listitem">
442 <xsl:copy-of select="$content"/> <xsl:text>&#10;</xsl:text>
443 <xsl:copy-of select="$default"/> <xsl:text>&#10;</xsl:text>
444 <xsl:copy-of select="$examples"/> <xsl:text>&#10;</xsl:text>
445 </xsl:element>
446 </xsl:element>
447 </xsl:template>
449 <xsl:template match="ulink">
450 <xsl:element name="ulink">
451 <xsl:attribute name="url">
452 <xsl:value-of select="@url"/>
453 </xsl:attribute>
455 <xsl:apply-templates/>
456 <xsl:if test="contains(@url,'http://') or contains(@url,'ftp://')">
457 <xsl:if test="$duplicate_ulinks='brackets'">
458 <xsl:text> (</xsl:text>
459 <xsl:value-of select="@url"/>
460 <xsl:text>)</xsl:text>
461 </xsl:if>
462 <xsl:if test="$duplicate_ulinks='footnote'">
463 <xsl:element name="footnote">
464 <xsl:element name="para">
465 <xsl:value-of select="@url"/>
466 </xsl:element>
467 </xsl:element>
468 </xsl:if>
469 </xsl:if>
470 </xsl:element>
471 </xsl:template>
473 <!-- Just ignore these -->
474 <xsl:template match="smbfile">
475 <xsl:apply-templates/>
476 </xsl:template>
478 <xsl:template match="quote">
479 <xsl:element name="quote">
480 <xsl:element name="emphasis">
481 <xsl:apply-templates/>
482 </xsl:element>
483 </xsl:element>
484 </xsl:template>
486 </xsl:stylesheet>