Updated bash and readline fixes to latest available from upstream.
[linux_from_scratch.git] / stylesheets / dump-commands.xsl
blob9e2af96e4a5863629a73f4b4004d835a7260d11e
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:exsl="http://exslt.org/common"
4 extension-element-prefixes="exsl"
5 version="1.0">
7 <!-- XSLT stylesheet to extract commands from [B,H]LFS books. -->
9 <xsl:variable name="newline">
10 <xsl:text>&#xA;</xsl:text>
11 </xsl:variable>
13 <xsl:template match="/">
14 <xsl:apply-templates select="//sect1"/>
15 </xsl:template>
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">
30 <xsl:choose>
31 <xsl:when test="string-length($position) = 1">
32 <xsl:text>00</xsl:text>
33 <xsl:value-of select="$position"/>
34 </xsl:when>
35 <xsl:when test="string-length($position) = 2">
36 <xsl:text>0</xsl:text>
37 <xsl:value-of select="$position"/>
38 </xsl:when>
39 <xsl:otherwise>
40 <xsl:value-of select="$position"/>
41 </xsl:otherwise>
42 </xsl:choose>
43 </xsl:variable>
44 <!-- Creating dirs and files -->
45 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
46 <xsl:apply-templates select=".//screen"/>
47 </exsl:document>
48 </xsl:template>
50 <xsl:template match="screen">
51 <xsl:if test="child::* = userinput">
52 <xsl:choose>
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"/>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:apply-templates select="userinput"/>
62 </xsl:otherwise>
63 </xsl:choose>
64 <xsl:value-of select="$newline"/>
65 </xsl:if>
66 </xsl:template>
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"/>
72 </xsl:if>
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"/>
78 </xsl:if>
79 </xsl:template>
81 <xsl:template match="replaceable">
82 <xsl:text>**EDITME</xsl:text>
83 <xsl:apply-templates/>
84 <xsl:text>EDITME**</xsl:text>
85 </xsl:template>
87 </xsl:stylesheet>