source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/profiling/profile-mode.xsl@ a210462

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since a210462 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 9.3 KB
Line 
1<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2 xmlns:saxon="http://icl.com/saxon"
3 exclude-result-prefixes="saxon"
4 version="1.0">
5
6<!-- Should be base URI for imagedata and so on fixed? -->
7<xsl:param name="profile.baseuri.fixup" select="true()"/>
8
9<!-- Copy all non-element nodes -->
10<xsl:template match="@*|text()|comment()|processing-instruction()" mode="profile">
11 <xsl:copy/>
12</xsl:template>
13
14<!-- Profile elements based on input parameters -->
15<xsl:template match="*" mode="profile">
16
17 <xsl:variable name="arch.content">
18 <xsl:if test="@arch">
19 <xsl:call-template name="cross.compare">
20 <xsl:with-param name="a" select="$profile.arch"/>
21 <xsl:with-param name="b" select="@arch"/>
22 </xsl:call-template>
23 </xsl:if>
24 </xsl:variable>
25 <xsl:variable name="arch.ok" select="not(@arch) or not($profile.arch) or
26 $arch.content != '' or @arch = ''"/>
27
28 <xsl:variable name="audience.content">
29 <xsl:if test="@audience">
30 <xsl:call-template name="cross.compare">
31 <xsl:with-param name="a" select="$profile.audience"/>
32 <xsl:with-param name="b" select="@audience"/>
33 </xsl:call-template>
34 </xsl:if>
35 </xsl:variable>
36 <xsl:variable name="audience.ok"
37 select="not(@audience) or not($profile.audience) or
38 $audience.content != '' or @audience = ''"/>
39
40 <xsl:variable name="condition.content">
41 <xsl:if test="@condition">
42 <xsl:call-template name="cross.compare">
43 <xsl:with-param name="a" select="$profile.condition"/>
44 <xsl:with-param name="b" select="@condition"/>
45 </xsl:call-template>
46 </xsl:if>
47 </xsl:variable>
48 <xsl:variable name="condition.ok" select="not(@condition) or not($profile.condition) or
49 $condition.content != '' or @condition = ''"/>
50
51 <xsl:variable name="conformance.content">
52 <xsl:if test="@conformance">
53 <xsl:call-template name="cross.compare">
54 <xsl:with-param name="a" select="$profile.conformance"/>
55 <xsl:with-param name="b" select="@conformance"/>
56 </xsl:call-template>
57 </xsl:if>
58 </xsl:variable>
59 <xsl:variable name="conformance.ok" select="not(@conformance) or not($profile.conformance) or
60 $conformance.content != '' or @conformance = ''"/>
61
62 <xsl:variable name="lang.content">
63 <xsl:if test="@lang | @xml:lang">
64 <xsl:call-template name="cross.compare">
65 <xsl:with-param name="a" select="$profile.lang"/>
66 <xsl:with-param name="b" select="(@lang | @xml:lang)[1]"/>
67 </xsl:call-template>
68 </xsl:if>
69 </xsl:variable>
70 <xsl:variable name="lang.ok" select="not(@lang | @xml:lang) or not($profile.lang) or
71 $lang.content != '' or @lang = '' or @xml:lang = ''"/>
72
73 <xsl:variable name="os.content">
74 <xsl:if test="@os">
75 <xsl:call-template name="cross.compare">
76 <xsl:with-param name="a" select="$profile.os"/>
77 <xsl:with-param name="b" select="@os"/>
78 </xsl:call-template>
79 </xsl:if>
80 </xsl:variable>
81 <xsl:variable name="os.ok" select="not(@os) or not($profile.os) or
82 $os.content != '' or @os = ''"/>
83
84 <xsl:variable name="revision.content">
85 <xsl:if test="@revision">
86 <xsl:call-template name="cross.compare">
87 <xsl:with-param name="a" select="$profile.revision"/>
88 <xsl:with-param name="b" select="@revision"/>
89 </xsl:call-template>
90 </xsl:if>
91 </xsl:variable>
92 <xsl:variable name="revision.ok" select="not(@revision) or not($profile.revision) or
93 $revision.content != '' or @revision = ''"/>
94
95 <xsl:variable name="revisionflag.content">
96 <xsl:if test="@revisionflag">
97 <xsl:call-template name="cross.compare">
98 <xsl:with-param name="a" select="$profile.revisionflag"/>
99 <xsl:with-param name="b" select="@revisionflag"/>
100 </xsl:call-template>
101 </xsl:if>
102 </xsl:variable>
103 <xsl:variable name="revisionflag.ok" select="not(@revisionflag) or not($profile.revisionflag) or
104 $revisionflag.content != '' or @revisionflag = ''"/>
105
106 <xsl:variable name="role.content">
107 <xsl:if test="@role">
108 <xsl:call-template name="cross.compare">
109 <xsl:with-param name="a" select="$profile.role"/>
110 <xsl:with-param name="b" select="@role"/>
111 </xsl:call-template>
112 </xsl:if>
113 </xsl:variable>
114 <xsl:variable name="role.ok" select="not(@role) or not($profile.role) or
115 $role.content != '' or @role = ''"/>
116
117 <xsl:variable name="security.content">
118 <xsl:if test="@security">
119 <xsl:call-template name="cross.compare">
120 <xsl:with-param name="a" select="$profile.security"/>
121 <xsl:with-param name="b" select="@security"/>
122 </xsl:call-template>
123 </xsl:if>
124 </xsl:variable>
125 <xsl:variable name="security.ok" select="not(@security) or not($profile.security) or
126 $security.content != '' or @security = ''"/>
127
128 <xsl:variable name="status.content">
129 <xsl:if test="@status">
130 <xsl:call-template name="cross.compare">
131 <xsl:with-param name="a" select="$profile.status"/>
132 <xsl:with-param name="b" select="@status"/>
133 </xsl:call-template>
134 </xsl:if>
135 </xsl:variable>
136 <xsl:variable name="status.ok" select="not(@status) or not($profile.status) or
137 $status.content != '' or @status = ''"/>
138
139 <xsl:variable name="userlevel.content">
140 <xsl:if test="@userlevel">
141 <xsl:call-template name="cross.compare">
142 <xsl:with-param name="a" select="$profile.userlevel"/>
143 <xsl:with-param name="b" select="@userlevel"/>
144 </xsl:call-template>
145 </xsl:if>
146 </xsl:variable>
147 <xsl:variable name="userlevel.ok" select="not(@userlevel) or not($profile.userlevel) or
148 $userlevel.content != '' or @userlevel = ''"/>
149
150 <xsl:variable name="vendor.content">
151 <xsl:if test="@vendor">
152 <xsl:call-template name="cross.compare">
153 <xsl:with-param name="a" select="$profile.vendor"/>
154 <xsl:with-param name="b" select="@vendor"/>
155 </xsl:call-template>
156 </xsl:if>
157 </xsl:variable>
158 <xsl:variable name="vendor.ok" select="not(@vendor) or not($profile.vendor) or
159 $vendor.content != '' or @vendor = ''"/>
160
161 <xsl:variable name="wordsize.content">
162 <xsl:if test="@wordsize">
163 <xsl:call-template name="cross.compare">
164 <xsl:with-param name="a" select="$profile.wordsize"/>
165 <xsl:with-param name="b" select="@wordsize"/>
166 </xsl:call-template>
167 </xsl:if>
168 </xsl:variable>
169 <xsl:variable name="wordsize.ok"
170 select="not(@wordsize) or not($profile.wordsize) or
171 $wordsize.content != '' or @wordsize = ''"/>
172
173 <xsl:variable name="attribute.content">
174 <xsl:if test="@*[local-name()=$profile.attribute]">
175 <xsl:call-template name="cross.compare">
176 <xsl:with-param name="a" select="$profile.value"/>
177 <xsl:with-param name="b" select="@*[local-name()=$profile.attribute]"/>
178 </xsl:call-template>
179 </xsl:if>
180 </xsl:variable>
181 <xsl:variable name="attribute.ok"
182 select="not(@*[local-name()=$profile.attribute]) or
183 not($profile.value) or $attribute.content != '' or
184 @*[local-name()=$profile.attribute] = '' or
185 not($profile.attribute)"/>
186
187 <xsl:if test="$arch.ok and
188 $audience.ok and
189 $condition.ok and
190 $conformance.ok and
191 $lang.ok and
192 $os.ok and
193 $revision.ok and
194 $revisionflag.ok and
195 $role.ok and
196 $security.ok and
197 $status.ok and
198 $userlevel.ok and
199 $vendor.ok and
200 $wordsize.ok and
201 $attribute.ok">
202 <xsl:copy>
203 <xsl:copy-of select="@*"/>
204
205 <!-- Entity references must be replaced with filereferences for temporary tree -->
206 <xsl:if test="@entityref and $profile.baseuri.fixup">
207 <xsl:attribute name="fileref">
208 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
209 </xsl:attribute>
210 </xsl:if>
211
212 <!-- xml:base is eventually added to the root element -->
213 <xsl:if test="not(../..) and $profile.baseuri.fixup">
214 <xsl:call-template name="add-xml-base"/>
215 </xsl:if>
216
217 <xsl:apply-templates select="node()" mode="profile"/>
218 </xsl:copy>
219 </xsl:if>
220</xsl:template>
221
222<!-- Returns non-empty string if list in $b contains one ore more values from list $a -->
223<xsl:template name="cross.compare">
224 <xsl:param name="a"/>
225 <xsl:param name="b"/>
226 <xsl:param name="sep" select="$profile.separator"/>
227 <xsl:variable name="head" select="substring-before(concat($a, $sep), $sep)"/>
228 <xsl:variable name="tail" select="substring-after($a, $sep)"/>
229 <xsl:if test="contains(concat($sep, $b, $sep), concat($sep, $head, $sep))">1</xsl:if>
230 <xsl:if test="$tail">
231 <xsl:call-template name="cross.compare">
232 <xsl:with-param name="a" select="$tail"/>
233 <xsl:with-param name="b" select="$b"/>
234 </xsl:call-template>
235 </xsl:if>
236</xsl:template>
237
238</xsl:stylesheet>
239
Note: See TracBrowser for help on using the repository browser.