Fix links for smbconfoptions.
[Samba.git] / docs / xslt / expand-sambadoc.xsl
blobaa7d54c0f77d77b6ab4954b3ee0a2a27723f9c7a
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:samba="http://samba.org/common"
11 version="1.1">
13 <xsl:import href="../settings.xsl"/>
15 <xsl:output method="xml" encoding="UTF-8" doctype-public="-//OASIS//DTD DocBook XML V4.2//EN" indent="yes" doctype-system="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"/>
17 <xsl:param name="xmlSambaNsUri" select="'http://samba.org/common'"/>
19 <xsl:template match="reference/refentry/refsect1">
20 <xsl:if test="title!='VERSION' and title!='AUTHOR'">
21 <xsl:element name="refsect1">
22 <xsl:if test="@id!=''">
23 <xsl:attribute name="id">
24 <xsl:value-of select="@id"/>
25 </xsl:attribute>
26 </xsl:if>
27 <xsl:apply-templates/>
28 </xsl:element>
29 </xsl:if>
30 </xsl:template>
32 <xsl:template match="translator">
33 <xsl:element name="othercredit">
34 <xsl:element name="author">
35 <xsl:apply-templates/>
36 <xsl:element name="contrib">
37 <xsl:text>Translation to </xsl:text><xsl:value-of select="@lang"/>
38 </xsl:element>
39 </xsl:element>
40 </xsl:element>
41 </xsl:template>
43 <xsl:template match="reference/refentry">
44 <xsl:element name="section">
45 <xsl:attribute name="id">
46 <xsl:value-of select="@id"/>
47 </xsl:attribute>
48 <xsl:element name="title">
49 <xsl:value-of select="refmeta/refentrytitle"/>
50 <!-- <xsl:text> (</xsl:text>
51 <xsl:value-of select="refnamediv/refpurpose"/>
52 <xsl:text>)</xsl:text>-->
53 </xsl:element>
54 <xsl:apply-templates/>
55 </xsl:element>
56 </xsl:template>
58 <xsl:template match="reference/refentry/refmeta"/>
60 <xsl:template match="reference/refentry/refnamediv"/>
62 <xsl:template match="reference">
63 <xsl:element name="appendix">
64 <xsl:attribute name="id">
65 <xsl:value-of select="@id"/>
66 </xsl:attribute>
67 <xsl:apply-templates/>
68 </xsl:element>
69 </xsl:template>
72 <!-- This is needed to copy content unchanged -->
73 <xsl:template match="@*|node()">
74 <xsl:copy>
75 <xsl:apply-templates select="@*|node()"/>
76 </xsl:copy>
77 </xsl:template>
79 <xsl:template match="smbconfexample/smbconfoption|smbconfblock/smbconfoption">
81 <xsl:element name="member">
82 <xsl:element name="indexterm">
83 <xsl:element name="primary">
84 <xsl:value-of select="@name"/>
85 </xsl:element>
86 </xsl:element>
87 <xsl:element name="parameter">
88 <xsl:text disable-output-escaping="yes">
89 &lt;?latex \hspace{1cm} ?&gt;
90 </xsl:text>
91 <xsl:value-of select="@name"/>
92 <xsl:choose>
93 <xsl:when test="text() != ''">
94 <xsl:text> = </xsl:text>
95 <xsl:value-of select="text()"/>
96 </xsl:when>
97 </xsl:choose>
98 </xsl:element>
99 </xsl:element>
100 </xsl:template>
102 <xsl:template match="smbconfexample/smbconfcomment|smbconfblock/smbconfcomment">
103 <xsl:text disable-output-escaping="yes">
104 &lt;?latex \hspace{1cm} ?&gt;
105 </xsl:text>
106 <xsl:element name="member">
107 <xsl:text># </xsl:text>
108 <xsl:apply-templates/>
109 </xsl:element>
110 </xsl:template>
112 <xsl:template match="smbconfexample/smbconfsection|smbconfblock/smbconfsection">
113 <xsl:element name="member">
114 <xsl:text> </xsl:text>
115 </xsl:element>
116 <xsl:element name="member">
117 <xsl:element name="parameter">
118 <xsl:apply-templates/>
119 </xsl:element>
120 </xsl:element>
121 </xsl:template>
123 <xsl:template match="smbconfoption">
124 <!-- Include an index term -->
125 <xsl:element name="indexterm">
126 <xsl:element name="primary">
127 <xsl:value-of select="@name"/>
128 </xsl:element>
129 </xsl:element>
131 <xsl:variable name="linkcontent">
132 <xsl:element name="parameter">
133 <xsl:attribute name="moreinfo">
134 <xsl:text>none</xsl:text>
135 </xsl:attribute>
136 <xsl:value-of select="@name"/>
137 </xsl:element>
139 <xsl:choose>
140 <xsl:when test="text() != ''">
141 <xsl:text> = </xsl:text>
142 <xsl:value-of select="text()"/>
143 </xsl:when>
144 </xsl:choose>
145 </xsl:variable>
147 <xsl:choose>
148 <xsl:when test="$noreference = 1">
149 <xsl:value-of select="$linkcontent"/>
150 </xsl:when>
151 <xsl:otherwise>
152 <xsl:element name="link">
153 <xsl:attribute name="linkend">
154 <xsl:value-of select="translate(translate(string(@name),' ',''),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
155 </xsl:attribute>
156 <xsl:value-of select="$linkcontent"/>
157 </xsl:element>
158 </xsl:otherwise>
159 </xsl:choose>
160 </xsl:template>
162 <!-- FIXME: Needs extension sometime -->
163 <xsl:template match="ntgroup|ntuser">
164 <xsl:element name="emphasis">
165 <xsl:apply-templates/>
166 </xsl:element>
167 </xsl:template>
169 <xsl:template match="smbconfexample">
170 <xsl:choose>
171 <xsl:when test="title = ''">
172 <xsl:message>
173 <xsl:text>Warning: smbconfexample does not have title!</xsl:text>
174 </xsl:message>
175 </xsl:when>
176 </xsl:choose>
177 <xsl:element name="example">
178 <xsl:choose>
179 <xsl:when test="@id != ''">
180 <xsl:attribute name="id">
181 <xsl:value-of select="@id"/>
182 </xsl:attribute>
183 </xsl:when>
184 </xsl:choose>
186 <xsl:element name="title">
187 <xsl:value-of select="title"/>
188 </xsl:element>
189 <xsl:element name="simplelist">
190 <xsl:apply-templates/>
191 </xsl:element>
192 </xsl:element>
193 </xsl:template>
195 <xsl:template match="smbconfexample/title">
196 </xsl:template>
198 <xsl:template match="smbconfblock">
199 <xsl:element name="simplelist">
200 <xsl:apply-templates/>
201 </xsl:element>
202 </xsl:template>
204 <xsl:template match="smbconfsection">
205 <xsl:element name="parameter">
206 <xsl:apply-templates/>
207 </xsl:element>
208 </xsl:template>
210 <xsl:template match="smbconfcomment">
211 <xsl:text># </xsl:text>
212 <xsl:apply-templates/>
213 </xsl:template>
215 <xsl:template match="smbfile">
216 <xsl:apply-templates/>
217 </xsl:template>
219 <xsl:template match="image">
220 <xsl:element name="figure">
221 <xsl:attribute name="id">
222 <xsl:choose>
223 <xsl:when test="@id != ''">
224 <xsl:value-of select="@id"/>
225 </xsl:when>
226 <xsl:otherwise>
227 <xsl:value-of select="imagefile"/>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:attribute>
232 <xsl:element name="title">
233 <xsl:if test="imagedescription = ''">
234 <xsl:message><xsl:text>imagedescription of image with id </xsl:text><xsl:value-of select="@id"/><xsl:text> is empty.</xsl:text></xsl:message>
235 </xsl:if>
236 <xsl:value-of select="imagedescription"/>
237 </xsl:element>
238 <xsl:element name="mediaobject">
239 <xsl:element name="imageobject">
240 <xsl:attribute name="role"><xsl:text>latex</xsl:text></xsl:attribute>
241 <xsl:element name="imagedata">
242 <xsl:attribute name="fileref">
243 <xsl:value-of select="$latex.imagebasedir"/><xsl:text>images/</xsl:text><xsl:value-of select="imagefile"/></xsl:attribute>
244 <xsl:attribute name="scale">
245 <xsl:choose>
246 <xsl:when test="@scale != ''">
247 <xsl:value-of select="@scale"/>
248 </xsl:when>
250 <xsl:when test="imagefile/@scale != ''">
251 <xsl:value-of select="imagefile/@scale"/>
252 </xsl:when>
254 <xsl:otherwise>
255 <xsl:text>50</xsl:text>
256 </xsl:otherwise>
257 </xsl:choose>
258 </xsl:attribute>
259 <xsl:attribute name="scalefit"><xsl:text>1</xsl:text></xsl:attribute>
260 </xsl:element>
261 </xsl:element>
262 <xsl:element name="imageobject">
263 <xsl:attribute name="role"><xsl:text>html</xsl:text></xsl:attribute>
264 <xsl:element name="imagedata">
265 <xsl:attribute name="fileref">
266 <xsl:text>images/</xsl:text><xsl:value-of select="imagefile"/><xsl:text>.png</xsl:text></xsl:attribute>
267 <xsl:attribute name="scale">
268 <xsl:choose>
269 <xsl:when test="@scale != ''">
270 <xsl:value-of select="@scale"/>
271 </xsl:when>
273 <xsl:when test="imagefile/@scale != ''">
274 <xsl:value-of select="imagefile/@scale"/>
275 </xsl:when>
277 <xsl:otherwise>
278 <xsl:text>100</xsl:text>
279 </xsl:otherwise>
280 </xsl:choose>
281 </xsl:attribute>
282 <xsl:attribute name="scalefit"><xsl:text>1</xsl:text></xsl:attribute>
283 </xsl:element>
284 </xsl:element>
285 <xsl:element name="imageobject">
286 <xsl:element name="imagedata">
287 <xsl:attribute name="fileref">
288 <xsl:text>images/</xsl:text><xsl:value-of select="imagefile"/><xsl:text>.png</xsl:text></xsl:attribute>
289 <xsl:attribute name="scale">
290 <xsl:choose>
291 <xsl:when test="@scale != ''">
292 <xsl:value-of select="@scale"/>
293 </xsl:when>
295 <xsl:when test="imagefile/@scale != ''">
296 <xsl:value-of select="imagefile/@scale"/>
297 </xsl:when>
299 <xsl:otherwise>
300 <xsl:text>50</xsl:text>
301 </xsl:otherwise>
302 </xsl:choose>
303 </xsl:attribute>
304 <xsl:attribute name="scalefit"><xsl:text>1</xsl:text></xsl:attribute>
305 </xsl:element>
306 </xsl:element>
308 </xsl:element>
309 </xsl:element>
310 </xsl:template>
312 <xsl:template match="description"><xsl:apply-templates/></xsl:template>
314 <xsl:template match="value"><xsl:apply-templates/></xsl:template>
316 <xsl:template match="synonym"><xsl:apply-templates/></xsl:template>
318 <xsl:template match="related"><xsl:apply-templates/></xsl:template>
320 <xsl:template match="//samba:parameterlist">
321 <xsl:apply-templates>
322 <xsl:sort select="varlistentry/term/anchor"/>
323 </xsl:apply-templates>
324 </xsl:template>
326 <xsl:template match="value/comment">
327 <xsl:text>&#10;# </xsl:text>
328 <xsl:apply-templates/>
329 </xsl:template>
331 <xsl:template match="//samba:parameter">
332 <!-- reconstruct varlistentry - not all of them will go into separate files
333 and also we must repair the main varlistentry itself.
335 <xsl:variable name="cname"><xsl:value-of select="translate(translate(string(@name),' ',''),
336 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
337 </xsl:variable>
339 <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
341 <xsl:variable name="anchor">
342 <xsl:element name="anchor">
343 <xsl:attribute name="id">
344 <xsl:value-of select="$cname"/>
345 </xsl:attribute>
346 </xsl:element>
347 </xsl:variable>
349 <xsl:variable name="context">
350 <xsl:text> (</xsl:text>
351 <xsl:value-of select="@context"/>
352 <xsl:text>)</xsl:text>
353 </xsl:variable>
355 <xsl:variable name="term">
356 <xsl:element name="term">
357 <xsl:copy-of select="$anchor"/>
358 <xsl:value-of select="@name"/>
359 <xsl:value-of select="$context"/>
360 </xsl:element>
361 </xsl:variable>
364 <!-- Generate list of examples -->
365 <xsl:variable name="examples">
366 <xsl:for-each select="value">
367 <xsl:if test="@type = 'example'">
368 <xsl:element name="para">
369 <xsl:text>Example: </xsl:text>
370 <xsl:element name="emphasis">
371 <xsl:element name="parameter">
372 <xsl:copy-of select="$name"/>
373 </xsl:element>
374 <xsl:text> = </xsl:text>
375 <xsl:apply-templates select="."/>
376 <xsl:text>&#10;</xsl:text>
377 </xsl:element>
378 <xsl:text>&#10;</xsl:text>
379 </xsl:element>
380 </xsl:if>
381 </xsl:for-each>
382 </xsl:variable>
384 <xsl:variable name="tdefault">
385 <xsl:for-each select="value">
386 <xsl:if test="@type = 'default'">
387 <xsl:element name="para">
388 <xsl:text>Default: </xsl:text>
389 <xsl:element name="emphasis">
390 <xsl:element name="parameter">
391 <xsl:copy-of select="$name"/>
392 </xsl:element>
393 <xsl:text> = </xsl:text>
394 <xsl:apply-templates select="."/>
395 <xsl:text>&#10;</xsl:text>
396 </xsl:element>
397 <xsl:text>&#10;</xsl:text>
398 </xsl:element>
399 </xsl:if>
400 </xsl:for-each>
401 </xsl:variable>
403 <xsl:variable name="default">
404 <xsl:choose>
405 <xsl:when test="$tdefault = ''">
406 <xsl:element name="para">
407 <xsl:element name="emphasis">
408 <xsl:text>No default</xsl:text>
409 </xsl:element>
410 </xsl:element>
411 </xsl:when>
412 <xsl:otherwise>
413 <xsl:copy-of select="$tdefault"/>
414 </xsl:otherwise>
415 </xsl:choose>
416 </xsl:variable>
418 <xsl:variable name="content">
419 <xsl:apply-templates select="description"/>
420 </xsl:variable>
422 <xsl:for-each select="synonym">
423 <xsl:element name="varlistentry">
424 <xsl:text>&#10;</xsl:text>
425 <xsl:element name="indexterm">
426 <xsl:attribute name="significance">
427 <xsl:text>preferred</xsl:text>
428 </xsl:attribute>
429 <xsl:element name="primary">
430 <xsl:value-of select="."/>
431 </xsl:element>
432 <xsl:element name="see">
433 <xsl:value-of select="$name"/>
434 </xsl:element>
435 </xsl:element>
437 <xsl:element name="term">
438 <xsl:element name="anchor">
439 <xsl:attribute name="id">
440 <xsl:value-of select="translate(translate(string(.),' ',''), 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
441 </xsl:attribute>
442 </xsl:element>
443 <xsl:value-of select="."/>
444 </xsl:element>
446 <xsl:element name="listitem">
447 <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>
448 </xsl:element>
449 </xsl:element>
450 </xsl:for-each>
452 <xsl:element name="varlistentry">
453 <xsl:text>&#10;</xsl:text>
454 <xsl:element name="indexterm">
455 <xsl:attribute name="significance">
456 <xsl:text>preferred</xsl:text>
457 </xsl:attribute>
458 <xsl:element name="primary">
459 <xsl:value-of select="@name"/>
460 </xsl:element>
461 </xsl:element>
462 <xsl:copy-of select="$term"/>
463 <xsl:element name="listitem">
464 <xsl:copy-of select="$content"/> <xsl:text>&#10;</xsl:text>
465 <xsl:copy-of select="$default"/> <xsl:text>&#10;</xsl:text>
466 <xsl:copy-of select="$examples"/> <xsl:text>&#10;</xsl:text>
467 </xsl:element>
468 </xsl:element>
469 </xsl:template>
471 <xsl:template match="ulink">
472 <xsl:element name="ulink">
473 <xsl:attribute name="url">
474 <xsl:value-of select="@url"/>
475 </xsl:attribute>
477 <xsl:apply-templates/>
478 <xsl:if test="contains(@url,'http://') or contains(@url,'ftp://')">
479 <xsl:if test="$duplicate_ulinks='brackets'">
480 <xsl:text> (</xsl:text>
481 <xsl:value-of select="@url"/>
482 <xsl:text>)</xsl:text>
483 </xsl:if>
484 <xsl:if test="$duplicate_ulinks='footnote'">
485 <xsl:element name="footnote">
486 <xsl:element name="para">
487 <xsl:value-of select="@url"/>
488 </xsl:element>
489 </xsl:element>
490 </xsl:if>
491 </xsl:if>
492 </xsl:element>
493 </xsl:template>
495 <!-- Just ignore these -->
496 <xsl:template match="smbfile">
497 <xsl:apply-templates/>
498 </xsl:template>
500 <xsl:template match="quote">
501 <xsl:element name="quote">
502 <xsl:element name="emphasis">
503 <xsl:apply-templates/>
504 </xsl:element>
505 </xsl:element>
506 </xsl:template>
508 </xsl:stylesheet>