source: BLFS/xsl/lfs_make_book.xsl@ a4af6811

ablfs-more legacy trunk
Last change on this file since a4af6811 was 619b313, checked in by Pierre Labastie <pierre@…>, 5 years ago

Various fixes and improvements coming from github:

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