source: BLFS/xsl/lfs_make_book.xsl@ e3f4b9a4

ablfs-more legacy trunk
Last change on this file since e3f4b9a4 was 2cef19f, checked in by Pierre Labastie <pierre@…>, 7 years ago

Fix "Id" property in lfs_make_book.xsl

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