source: BLFS/xsl/lfs_make_book.xsl@ 4c36783

ablfs-more trunk
Last change on this file since 4c36783 was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

  • Property mode set to 100644
File size: 8.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version="1.0">
5
6 <xsl:key name="idlfs" match="sect1" use="sect1info/productname"/>
7
8 <xsl:template name="detect-lfs">
9 <xsl:param name="package"/>
10 <xsl:param name="lfsbook"/>
11 <xsl:choose>
12 <xsl:when test="$package='gcc' or
13 $package='dbus' or
14 $package='vim' or
15 $package='systemd' or
16 $package='Python' or
17 $package='shadow'"/>
18 <xsl:when test="$package='bootscripts'">true</xsl:when>
19 <xsl:when test="$package='kernel'">true</xsl:when>
20 <xsl:when test="$package='LFS-Release'">true</xsl:when>
21 <xsl:otherwise>
22 <xsl:for-each select="document($lfsbook)">
23 <xsl:copy-of select="boolean(key('idlfs',$package)/ancestor::chapter[@id='chapter-building-system'])"/>
24 </xsl:for-each>
25 </xsl:otherwise>
26 </xsl:choose>
27 </xsl:template>
28
29 <xsl:template name="process-lfs">
30 <xsl:param name="package"/>
31 <xsl:param name="lfsbook"/>
32 <xsl:choose>
33 <xsl:when test="$package='gcc' or
34 $package='dbus' or
35 $package='vim' or
36 $package='systemd' or
37 $package='Python' or
38 $package='shadow'"/>
39 <xsl:when test="$package='bootscripts'">
40 <xsl:for-each select="document($lfsbook)">
41 <xsl:apply-templates select="key('idlfs',$package)[ancestor::chapter/@id='chapter-config']" mode="lfs"/>
42 </xsl:for-each>
43 </xsl:when>
44 <xsl:when test="$package='kernel'">
45 <xsl:for-each select="document($lfsbook)">
46 <xsl:apply-templates select="key('idlfs',$package)[ancestor::chapter/@id='chapter-bootable']" mode="lfs"/>
47 </xsl:for-each>
48 </xsl:when>
49 <xsl:when test="$package='LFS-Release'">
50 <sect1 id="LFS-Release">
51 <xsl:apply-templates select="document($lfsbook)//sect1[@id='ch-finish-theend']/*" mode="lfs-remap"/>
52 </sect1>
53 </xsl:when>
54 <xsl:otherwise>
55 <xsl:for-each select="document($lfsbook)">
56 <xsl:apply-templates select="key('idlfs',$package)[ancestor::chapter/@id='chapter-building-system']" mode="lfs"/>
57 </xsl:for-each>
58 </xsl:otherwise>
59 </xsl:choose>
60 </xsl:template>
61
62 <xsl:template match="*" mode="lfs">
63 <xsl:choose>
64<!--variablelist may contain id attributes equal to the name of the package,
65 which generates non-unique id. They are of not much use (short descriptions)
66 here. So just remove them-->
67 <xsl:when test="self::variablelist"/>
68<!--The id's in lfs are of the form ch-xxx-package. We do not want to
69 use that for file names and the like. So change the id-->
70 <xsl:when test="self::sect1">
71 <xsl:element name="sect1">
72 <xsl:attribute name="id">
73 <xsl:choose>
74 <xsl:when
75 test="./sect1info/productname=
76 'bootscripts'">lfs-bootscripts</xsl:when>
77 <xsl:otherwise>
78 <xsl:value-of select="./sect1info/productname"/>
79 </xsl:otherwise>
80 </xsl:choose>
81 </xsl:attribute>
82 <xsl:apply-templates mode="lfs"/>
83 </xsl:element>
84 </xsl:when>
85 <xsl:when test=".//sect2">
86 <xsl:element name="{name()}">
87 <xsl:for-each select="attribute::*">
88 <xsl:attribute name="{name()}">
89 <xsl:value-of select="."/>
90 </xsl:attribute>
91 </xsl:for-each>
92 <xsl:apply-templates mode="lfs"/>
93 </xsl:element>
94 </xsl:when>
95 <xsl:when test="self::sect2[@role='package']">
96 <xsl:variable name="url" select="../sect1info/address/text()"/>
97 <xsl:variable name="md5" select="//sect1[@id='materials-packages']//ulink[@url=$url]/../following-sibling::para/literal/text()"/>
98 <xsl:variable name="patch">
99 <xsl:call-template name="find-patch"/>
100 </xsl:variable>
101 <sect2 role="package">
102 <xsl:copy-of select="./*"/>
103 <bridgehead renderas="sect3">Package Information</bridgehead>
104 <itemizedlist spacing="compact">
105 <listitem>
106 <para>
107 Download (HTTP): <!--<xsl:element name="ulink">
108 <xsl:attribute name="url">
109 <xsl:value-of select="$url"/>
110 </xsl:attribute>
111 </xsl:element>--><ulink url="{$url}"/>
112 </para>
113 </listitem>
114 <listitem>
115 <para>
116 Download (FTP): <ulink url=" "/>
117 </para>
118 </listitem>
119 <listitem>
120 <para>
121 Download MD5 sum: <xsl:value-of select="$md5"/>
122 </para>
123 </listitem>
124 </itemizedlist>
125 <xsl:if test="string-length($patch)&gt;10">
126 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
127 <itemizedlist spacing="compact">
128 <listitem>
129 <para>
130 Required patch:
131 <ulink url="{$patch}"/>
132 </para>
133 </listitem>
134 </itemizedlist>
135 </xsl:if>
136 </sect2>
137 </xsl:when>
138 <xsl:when test="self::sect2[@role='installation']">
139 <sect2 role="installation">
140 <xsl:apply-templates mode="lfs-remap"/>
141 </sect2>
142 </xsl:when>
143 <xsl:when test="self::sect2[@role='configuration']">
144 <sect2 role="configuration">
145 <xsl:apply-templates mode="lfs-remap"/>
146 </sect2>
147 </xsl:when>
148 <xsl:when test="self::sect2">
149 <xsl:element name="sect2">
150 <xsl:for-each select="attribute::*">
151 <xsl:attribute name="{name()}">
152 <xsl:value-of select="."/>
153 </xsl:attribute>
154 </xsl:for-each>
155 <xsl:apply-templates mode="lfs"/>
156 </xsl:element>
157 </xsl:when>
158 <xsl:otherwise><!--
159 <xsl:element name="{name()}">
160 <xsl:for-each select="attribute::*">
161 <xsl:attribute name="{name()}">
162 <xsl:value-of select="."/>
163 </xsl:attribute>
164 </xsl:for-each>
165 <xsl:apply-templates/>
166 </xsl:element>-->
167 <xsl:copy-of select="."/>
168 </xsl:otherwise>
169 </xsl:choose>
170 </xsl:template>
171
172 <xsl:template name="find-patch">
173 <xsl:variable name="patch-command" select="..//userinput[contains(string(),'patch -Np1')]/text()"/>
174 <xsl:variable name="patch" select="substring-after($patch-command,'../')"/>
175 <xsl:if test="string-length($patch) &gt; 10">
176 <xsl:value-of select="//sect1[@id='materials-patches']//ulink/@url[contains(string(),$patch)]"/>
177 </xsl:if>
178 </xsl:template>
179
180 <xsl:template match="*" mode="lfs-remap">
181 <xsl:choose>
182 <xsl:when test=".//screen">
183 <xsl:element name="{name()}">
184 <xsl:for-each select="attribute::*">
185 <xsl:attribute name="{name()}">
186 <xsl:value-of select="."/>
187 </xsl:attribute>
188 </xsl:for-each>
189 <xsl:apply-templates mode="lfs-remap"/>
190 </xsl:element>
191 </xsl:when>
192 <xsl:when test="self::screen">
193 <xsl:choose>
194<!-- Since we are using the *-full.xml files, revisions have already been
195 selected, so no need to bother about revision attributes-->
196 <xsl:when test="@role='nodump'">
197 <xsl:copy-of select="."/>
198 </xsl:when>
199 <xsl:when test="contains(string(),'&lt;your name here&gt;')">
200 <screen role="root"><userinput>
201 <xsl:copy-of
202 select="substring-before(string(),'&lt;your name here&gt;')"/>
203 <xsl:text>jhalfs</xsl:text>
204 <xsl:copy-of
205 select="substring-after(string(),'&lt;your name here&gt;')"/>
206 </userinput></screen>
207 </xsl:when>
208 <xsl:when test="./userinput[@remap='install' or not(@remap)]">
209 <screen role="root">
210 <xsl:copy-of select="./*"/>
211 </screen>
212 </xsl:when>
213 <xsl:when test="./userinput[@remap='test']">
214 <para><command>
215 <xsl:copy-of select="./userinput/text()"/>
216 </command></para>
217 </xsl:when>
218 <xsl:otherwise>
219 <xsl:copy-of select="."/>
220 </xsl:otherwise>
221 </xsl:choose>
222 </xsl:when>
223 <xsl:otherwise><!--
224 <xsl:copy-of select="."/>-->
225 <xsl:element name="{name()}">
226 <xsl:for-each select="attribute::*">
227 <xsl:attribute name="{name()}">
228 <xsl:value-of select="."/>
229 </xsl:attribute>
230 </xsl:for-each>
231 <xsl:apply-templates mode="sect1"/>
232 </xsl:element>
233 </xsl:otherwise>
234 </xsl:choose>
235 </xsl:template>
236</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.