Add new framework for smb.conf(5). Please read README before trying to compile.
[Samba/gebeck_regimport.git] / docs / docbook / smbdotconf / split-original-smb.conf.xsl
blob7a6a2b920a1d879d85dd4f2364e7185f83a25d6b
1 <?xml version='1.0'?>
2 <!-- vim:set sts=2 shiftwidth=2 syntax=xml: -->
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:exsl="http://exslt.org/common"
5 xmlns:samba="http://samba.org/common"
6 version="1.1"
7 extension-element-prefixes="exsl">
9 <xsl:output method="xml"/>
11 <xsl:param name="output.dir.name" select="'test/'"/>
13 <!-- This is needed to copy content unchanged -->
14 <xsl:template match="@*|node()">
15 <xsl:copy>
16 <xsl:apply-templates select="@*|node()"/>
17 </xsl:copy>
18 </xsl:template>
20 <!-- Parse all varlistentries and extract those of them which are descriptions of smb.conf
21 parameters. We determine them by existence of <anchor> element inside <term> element.
22 If <anchor> is there, then its 'id' attribute is translated to lower case and is used
23 as basis for file name for that parameter.
24 -->
25 <xsl:template match="varlistentry">
26 <xsl:variable name="output.dir.name" select="$output.dir.name"/>
27 <!-- Extract anchor's 'id' and translate it to lower case -->
28 <xsl:variable name="fname">
29 <xsl:value-of select="translate(string(term/anchor/@id),
30 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
31 </xsl:variable>
32 <!-- reconstruct varlistentry - not all of them will go into separate files
33 and also we must repair the main varlistentry itself.
34 -->
35 <xsl:variable name="content">
36 <xsl:apply-templates/>
37 </xsl:variable>
38 <!-- Now put varlistentry into separate file _if_ it has anchor associated with it -->
39 <xsl:choose>
40 <xsl:when test="$fname != ''">
41 <!-- full file name -->
42 <xsl:variable name="filename"><xsl:value-of select="$output.dir.name"/><xsl:value-of select="$fname"/>.xml</xsl:variable>
43 <!-- Debug message for an operator, just to show progress of processing :) -->
44 <xsl:message>
45 <xsl:text>Writing </xsl:text>
46 <xsl:value-of select="$filename"/>
47 <xsl:text> for </xsl:text>
48 <xsl:value-of select="name(.)"/>
49 <xsl:if test="term/anchor/@id">
50 <xsl:text>(</xsl:text>
51 <xsl:value-of select="term/anchor/@id"/>
52 <xsl:text>)</xsl:text>
53 </xsl:if>
54 </xsl:message>
55 <!-- Write finally varlistentry to a separate file -->
56 <exsl:document href="{$filename}"
57 method="xml"
58 encoding="UTF-8"
59 indent="yes"
60 omit-xml-declaration="yes">
61 <xsl:element name="samba:parameter">
62 <xsl:copy-of select="$content"/>
63 </xsl:element>
64 </exsl:document>
65 <xsl:text disable-output-escaping="yes">&amp;smb.</xsl:text>
66 <xsl:value-of select="$fname"/>
67 <xsl:text>;</xsl:text>
68 </xsl:when>
69 <!-- this was a varlistentry w/o anchor associated, just dump it to the main document -->
70 <xsl:otherwise>
71 <xsl:element name="varlistentry">
72 <xsl:copy-of select="$content"/>
73 </xsl:element>
74 </xsl:otherwise>
75 </xsl:choose>
76 </xsl:template>
78 </xsl:stylesheet>