source: stylesheets/dump-commands.xsl@ 81af1bb

Last change on this file since 81af1bb was bf8c11f, checked in by Jim Gifford <clfs@…>, 19 years ago

r627@server (orig r625): jim | 2005-10-31 12:59:34 -0800
Import of Cross-LFS Book

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[bf8c11f]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">
6
7<!-- XSLT stylesheet to extract commands from [B,H]LFS books. -->
8
9 <xsl:template match="/">
10 <xsl:apply-templates select="//sect1"/>
11 </xsl:template>
12
13 <xsl:template match="sect1">
14 <!-- The dirs names -->
15 <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
16 <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
17 <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
18 <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
19 <!-- The file names -->
20 <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
21 <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
22 <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
23 <!-- The build order -->
24 <xsl:variable name="position" select="position()"/>
25 <xsl:variable name="order">
26 <xsl:choose>
27 <xsl:when test="string-length($position) = 1">
28 <xsl:text>00</xsl:text>
29 <xsl:value-of select="$position"/>
30 </xsl:when>
31 <xsl:when test="string-length($position) = 2">
32 <xsl:text>0</xsl:text>
33 <xsl:value-of select="$position"/>
34 </xsl:when>
35 <xsl:otherwise>
36 <xsl:value-of select="$position"/>
37 </xsl:otherwise>
38 </xsl:choose>
39 </xsl:variable>
40 <!-- Creating dirs and files -->
41 <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
42 <xsl:apply-templates select=".//screen"/>
43 </exsl:document>
44 </xsl:template>
45
46 <xsl:template match="screen">
47 <xsl:if test="child::* = userinput">
48 <xsl:choose>
49 <xsl:when test="@role = 'nodump'"/>
50 <xsl:when test="@role = 'root'">
51 <xsl:text>&#xA;</xsl:text>
52 <xsl:text># Run this as root</xsl:text>
53 <xsl:apply-templates select="userinput"/>
54 <xsl:text># End root commands</xsl:text>
55 <xsl:text>&#xA;</xsl:text>
56 </xsl:when>
57 <xsl:otherwise>
58 <xsl:apply-templates select="userinput"/>
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:if>
62 </xsl:template>
63
64 <xsl:template match="userinput">
65 <xsl:text>&#xA;</xsl:text>
66 <xsl:if test=".//replaceable">
67 <xsl:text># This block must be edited to suit your needs.</xsl:text>
68 </xsl:if>
69 <xsl:text>&#xA;</xsl:text>
70 <xsl:apply-templates/>
71 <xsl:text>&#xA;</xsl:text>
72 <xsl:if test=".//replaceable">
73 <xsl:text># End of editable block.</xsl:text>
74 </xsl:if>
75 <xsl:text>&#xA;</xsl:text>
76 </xsl:template>
77
78 <xsl:template match="replaceable">
79 <xsl:text>**EDITME</xsl:text>
80 <xsl:apply-templates/>
81 <xsl:text>EDITME**</xsl:text>
82 </xsl:template>
83
84</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.