2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
3 xmlns:
exsl=
"http://exslt.org/common"
4 extension-element-prefixes=
"exsl"
7 <!-- XSLT stylesheet to extract commands from [B,H]LFS books. -->
9 <xsl:variable name=
"newline">
10 <xsl:text>
</xsl:text>
13 <xsl:template match=
"/">
14 <xsl:apply-templates select=
"//sect1"/>
17 <xsl:template match=
"sect1">
18 <!-- The dirs names -->
19 <xsl:variable name=
"pi-dir" select=
"../processing-instruction('dbhtml')"/>
20 <xsl:variable name=
"pi-dir-value" select=
"substring-after($pi-dir,'dir=')"/>
21 <xsl:variable name=
"quote-dir" select=
"substring($pi-dir-value,1,1)"/>
22 <xsl:variable name=
"dirname" select=
"substring-before(substring($pi-dir-value,2),$quote-dir)"/>
23 <!-- The file names -->
24 <xsl:variable name=
"pi-file" select=
"processing-instruction('dbhtml')"/>
25 <xsl:variable name=
"pi-file-value" select=
"substring-after($pi-file,'filename=')"/>
26 <xsl:variable name=
"filename" select=
"substring-before(substring($pi-file-value,2),'.html')"/>
27 <!-- The build order -->
28 <xsl:variable name=
"position" select=
"position()"/>
29 <xsl:variable name=
"order">
31 <xsl:when test=
"string-length($position) = 1">
32 <xsl:text>00</xsl:text>
33 <xsl:value-of select=
"$position"/>
35 <xsl:when test=
"string-length($position) = 2">
36 <xsl:text>0</xsl:text>
37 <xsl:value-of select=
"$position"/>
40 <xsl:value-of select=
"$position"/>
44 <!-- Creating dirs and files -->
45 <exsl:document href=
"{$dirname}/{$order}-{$filename}" method=
"text">
46 <xsl:apply-templates select=
".//screen"/>
50 <xsl:template match=
"screen">
51 <xsl:if test=
"child::* = userinput">
53 <xsl:when test=
"@role = 'root'">
54 <xsl:text># Run this as root
</xsl:text>
55 <xsl:value-of select=
"$newline"/>
56 <xsl:apply-templates select=
"userinput"/>
57 <xsl:text># End root commands
</xsl:text>
58 <xsl:value-of select=
"$newline"/>
61 <xsl:apply-templates select=
"userinput"/>
64 <xsl:value-of select=
"$newline"/>
68 <xsl:template match=
"userinput">
69 <xsl:if test=
".//replaceable">
70 <xsl:text># This block must be edited to suit your needs.
</xsl:text>
71 <xsl:value-of select=
"$newline"/>
73 <xsl:apply-templates/>
74 <xsl:value-of select=
"$newline"/>
75 <xsl:if test=
".//replaceable">
76 <xsl:text># End of editable block.
</xsl:text>
77 <xsl:value-of select=
"$newline"/>
81 <xsl:template match=
"replaceable">
82 <xsl:text>**EDITME
</xsl:text>
83 <xsl:apply-templates/>
84 <xsl:text>EDITME**
</xsl:text>