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"
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()">
16 <xsl:apply-templates select=
"@*|node()"/>
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.
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')"/>
32 <!-- reconstruct varlistentry - not all of them will go into separate files
33 and also we must repair the main varlistentry itself.
35 <xsl:variable name=
"content">
36 <xsl:apply-templates/>
38 <!-- Now put varlistentry into separate file _if_ it has anchor associated with it -->
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 :) -->
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>
55 <!-- Write finally varlistentry to a separate file -->
56 <exsl:document href=
"{$filename}"
60 omit-xml-declaration=
"yes">
61 <xsl:element name=
"samba:parameter">
62 <xsl:copy-of select=
"$content"/>
65 <xsl:text disable-output-escaping=
"yes">&smb.
</xsl:text>
66 <xsl:value-of select=
"$fname"/>
67 <xsl:text>;
</xsl:text>
69 <!-- this was a varlistentry w/o anchor associated, just dump it to the main document -->
71 <xsl:element name=
"varlistentry">
72 <xsl:copy-of select=
"$content"/>