~ubuntu-branches/ubuntu/trusty/yelp-xsl/trusty

« back to all changes in this revision

Viewing changes to xslt/docbook/common/db-profile.xsl

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2013-10-17 00:05:53 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20131017000553-4rje2hk2j69y05w4
Tags: upstream-3.10.1
ImportĀ upstreamĀ versionĀ 3.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
 
2
<!--
 
3
This program is free software; you can redistribute it and/or modify it under
 
4
the terms of the GNU Lesser General Public License as published by the Free
 
5
Software Foundation; either version 2 of the License, or (at your option) any
 
6
later version.
 
7
 
 
8
This program is distributed in the hope that it will be useful, but WITHOUT
 
9
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
10
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 
11
details.
 
12
 
 
13
You should have received a copy of the GNU Lesser General Public License
 
14
along with this program; see the file COPYING.LGPL.  If not, write to the
 
15
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
16
02111-1307, USA.
 
17
-->
 
18
 
 
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
20
                xmlns:str="http://exslt.org/strings"
 
21
                exclude-result-prefixes="str"
 
22
                version="1.0">
 
23
 
 
24
<!--!!==========================================================================
 
25
DocBook Profiling
 
26
Support for DocBook effectivity attributes
 
27
:Revision:version="3.10" date="2013-08-12" status="final"
 
28
 
 
29
This stylesheet contains utilities for handling conditional processing
 
30
in DocBook documents.
 
31
-->
 
32
 
 
33
 
 
34
<!--@@==========================================================================
 
35
db.profile.arch
 
36
The list of architectures for conditional processing.
 
37
:Revision:version="3.10" date="2013-08-12" status="final"
 
38
 
 
39
This parameter takes a semicolon-separated list of values to match against the
 
40
#{arch} attribute for conditional processing.
 
41
-->
 
42
<xsl:param name="db.profile.arch" select="''"/>
 
43
 
 
44
 
 
45
<!--@@==========================================================================
 
46
db.profile.audience
 
47
The list of audiences for conditional processing.
 
48
:Revision:version="3.10" date="2013-08-12" status="final"
 
49
 
 
50
This parameter takes a semicolon-separated list of values to match against the
 
51
#{audience} attribute for conditional processing.
 
52
-->
 
53
<xsl:param name="db.profile.audience" select="''"/>
 
54
 
 
55
 
 
56
<!--@@==========================================================================
 
57
db.profile.condition
 
58
The list of application-specific conditions for conditional processing.
 
59
:Revision:version="3.10" date="2013-08-12" status="final"
 
60
 
 
61
This parameter takes a semicolon-separated list of values to match against the
 
62
#{condition} attribute for conditional processing.
 
63
-->
 
64
<xsl:param name="db.profile.condition" select="''"/>
 
65
 
 
66
 
 
67
<!--@@==========================================================================
 
68
db.profile.conformance
 
69
The list of conformance characteristics for conditional processing.
 
70
:Revision:version="3.10" date="2013-08-12" status="final"
 
71
 
 
72
This parameter takes a semicolon-separated list of values to match against the
 
73
#{conformance} attribute for conditional processing.
 
74
-->
 
75
<xsl:param name="db.profile.conformance" select="''"/>
 
76
 
 
77
 
 
78
<!--@@==========================================================================
 
79
db.profile.os
 
80
The list of operating systems for conditional processing.
 
81
:Revision:version="3.10" date="2013-08-12" status="final"
 
82
 
 
83
This parameter takes a semicolon-separated list of values to match against the
 
84
#{os} attribute for conditional processing.
 
85
-->
 
86
<xsl:param name="db.profile.os" select="''"/>
 
87
 
 
88
 
 
89
<!--@@==========================================================================
 
90
db.profile.outputformat
 
91
The list of output formats for conditional processing.
 
92
:Revision:version="3.10" date="2013-08-12" status="final"
 
93
 
 
94
This parameter takes a semicolon-separated list of values to match against the
 
95
#{outputformat} attribute for conditional processing.
 
96
-->
 
97
<xsl:param name="db.profile.os" select="''"/>
 
98
 
 
99
 
 
100
<!--@@==========================================================================
 
101
db.profile.revision
 
102
The list of editorial revisions for conditional processing.
 
103
:Revision:version="3.10" date="2013-08-12" status="final"
 
104
 
 
105
This parameter takes a semicolon-separated list of values to match against the
 
106
#{revision} attribute for conditional processing.
 
107
-->
 
108
<xsl:param name="db.profile.revision" select="''"/>
 
109
 
 
110
 
 
111
<!--@@==========================================================================
 
112
db.profile.security
 
113
The list of security levels for conditional processing.
 
114
:Revision:version="3.10" date="2013-08-12" status="final"
 
115
 
 
116
This parameter takes a semicolon-separated list of values to match against the
 
117
#{security} attribute for conditional processing.
 
118
-->
 
119
<xsl:param name="db.profile.security" select="''"/>
 
120
 
 
121
 
 
122
<!--@@==========================================================================
 
123
db.profile.userlevel
 
124
The list of user experience levels for conditional processing.
 
125
:Revision:version="3.10" date="2013-08-12" status="final"
 
126
 
 
127
This parameter takes a semicolon-separated list of values to match against the
 
128
#{userlevel} attribute for conditional processing.
 
129
-->
 
130
<xsl:param name="db.profile.userlevel" select="''"/>
 
131
 
 
132
 
 
133
<!--@@==========================================================================
 
134
db.profile.vendor
 
135
The list of vendors for conditional processing.
 
136
:Revision:version="3.10" date="2013-08-12" status="final"
 
137
 
 
138
This parameter takes a semicolon-separated list of values to match against the
 
139
#{vendor} attribute for conditional processing.
 
140
-->
 
141
<xsl:param name="db.profile.vendor" select="''"/>
 
142
 
 
143
 
 
144
<!--@@==========================================================================
 
145
db.profile.wordsize
 
146
The list of word sizes for conditional processing.
 
147
:Revision:version="3.10" date="2013-08-12" status="final"
 
148
 
 
149
This parameter takes a semicolon-separated list of values to match against the
 
150
#{wordsize} attribute for conditional processing.
 
151
-->
 
152
<xsl:param name="db.profile.wordsize" select="''"/>
 
153
 
 
154
 
 
155
<!--**==========================================================================
 
156
db.profile.test
 
157
Test if an element should be shown based on profiling attributes.
 
158
:Revision:version="3.10" date="2013-08-12" status="final"
 
159
$node: The element to check the condition for.
 
160
 
 
161
This template looks at all the profiling attributes of the element ${node}:
 
162
#{arch}, #{audience}, #{condition}, #{conformance}, #{os}, #{outputformat},
 
163
#{revision}, #{security}, #{userlevel}, #{vendor}, and #{wordsize}. It returns
 
164
the string #{"true"} if all attributes present match the corresponding parameter
 
165
in this stylesheet. Attributes and parameters can both be lists, separated by
 
166
semicolons. An attribute matches a parameter if there is at least one value in
 
167
common between the two.
 
168
-->
 
169
<xsl:template name="db.profile.test">
 
170
  <xsl:param name="node" select="."/>
 
171
 
 
172
  <xsl:variable name="testnot">
 
173
    <xsl:if test="$node/@arch != '' and $db.profile.arch != ''">
 
174
      <xsl:variable name="testarch">
 
175
        <xsl:call-template name="_db.profile.test.compare">
 
176
          <xsl:with-param name="attr" select="$node/@arch"/>
 
177
          <xsl:with-param name="value" select="$db.profile.arch"/>
 
178
        </xsl:call-template>
 
179
      </xsl:variable>
 
180
      <xsl:if test="$testarch = ''">
 
181
        <xsl:text>x</xsl:text>
 
182
      </xsl:if>
 
183
    </xsl:if>
 
184
 
 
185
    <xsl:if test="$node/@audience != '' and $db.profile.audience != ''">
 
186
      <xsl:variable name="testaudience">
 
187
        <xsl:call-template name="_db.profile.test.compare">
 
188
          <xsl:with-param name="attr" select="$node/@audience"/>
 
189
          <xsl:with-param name="value" select="$db.profile.audience"/>
 
190
        </xsl:call-template>
 
191
      </xsl:variable>
 
192
      <xsl:if test="$testaudience = ''">
 
193
        <xsl:text>x</xsl:text>
 
194
      </xsl:if>
 
195
    </xsl:if>
 
196
 
 
197
    <xsl:if test="$node/@condition != '' and $db.profile.condition != ''">
 
198
      <xsl:variable name="testcondition">
 
199
        <xsl:call-template name="_db.profile.test.compare">
 
200
          <xsl:with-param name="attr" select="$node/@condition"/>
 
201
          <xsl:with-param name="value" select="$db.profile.condition"/>
 
202
        </xsl:call-template>
 
203
      </xsl:variable>
 
204
      <xsl:if test="$testcondition = ''">
 
205
        <xsl:text>x</xsl:text>
 
206
      </xsl:if>
 
207
    </xsl:if>
 
208
 
 
209
    <xsl:if test="$node/@conformance != '' and $db.profile.conformance != ''">
 
210
      <xsl:variable name="testconformance">
 
211
        <xsl:call-template name="_db.profile.test.compare">
 
212
          <xsl:with-param name="attr" select="$node/@conformance"/>
 
213
          <xsl:with-param name="value" select="$db.profile.conformance"/>
 
214
        </xsl:call-template>
 
215
      </xsl:variable>
 
216
      <xsl:if test="$testconformance = ''">
 
217
        <xsl:text>x</xsl:text>
 
218
      </xsl:if>
 
219
    </xsl:if>
 
220
 
 
221
    <xsl:if test="$node/@os != '' and $db.profile.os != ''">
 
222
      <xsl:variable name="testos">
 
223
        <xsl:call-template name="_db.profile.test.compare">
 
224
          <xsl:with-param name="attr" select="$node/@os"/>
 
225
          <xsl:with-param name="value" select="$db.profile.os"/>
 
226
        </xsl:call-template>
 
227
      </xsl:variable>
 
228
      <xsl:if test="$testos = ''">
 
229
        <xsl:text>x</xsl:text>
 
230
      </xsl:if>
 
231
    </xsl:if>
 
232
 
 
233
    <xsl:if test="$node/@outputformat != '' and $db.profile.outputformat != ''">
 
234
      <xsl:variable name="testoutputformat">
 
235
        <xsl:call-template name="_db.profile.test.compare">
 
236
          <xsl:with-param name="attr" select="$node/@outputformat"/>
 
237
          <xsl:with-param name="value" select="$db.profile.outputformat"/>
 
238
        </xsl:call-template>
 
239
      </xsl:variable>
 
240
      <xsl:if test="$testoutputformat = ''">
 
241
        <xsl:text>x</xsl:text>
 
242
      </xsl:if>
 
243
    </xsl:if>
 
244
 
 
245
    <xsl:if test="$node/@revision != '' and $db.profile.revision != ''">
 
246
      <xsl:variable name="testrevision">
 
247
        <xsl:call-template name="_db.profile.test.compare">
 
248
          <xsl:with-param name="attr" select="$node/@revision"/>
 
249
          <xsl:with-param name="value" select="$db.profile.revision"/>
 
250
        </xsl:call-template>
 
251
      </xsl:variable>
 
252
      <xsl:if test="$testrevision = ''">
 
253
        <xsl:text>x</xsl:text>
 
254
      </xsl:if>
 
255
    </xsl:if>
 
256
 
 
257
    <xsl:if test="$node/@security != '' and $db.profile.security != ''">
 
258
      <xsl:variable name="testsecurity">
 
259
        <xsl:call-template name="_db.profile.test.compare">
 
260
          <xsl:with-param name="attr" select="$node/@security"/>
 
261
          <xsl:with-param name="value" select="$db.profile.security"/>
 
262
        </xsl:call-template>
 
263
      </xsl:variable>
 
264
      <xsl:if test="$testsecurity = ''">
 
265
        <xsl:text>x</xsl:text>
 
266
      </xsl:if>
 
267
    </xsl:if>
 
268
 
 
269
    <xsl:if test="$node/@userlevel != '' and $db.profile.userlevel != ''">
 
270
      <xsl:variable name="testuserlevel">
 
271
        <xsl:call-template name="_db.profile.test.compare">
 
272
          <xsl:with-param name="attr" select="$node/@userlevel"/>
 
273
          <xsl:with-param name="value" select="$db.profile.userlevel"/>
 
274
        </xsl:call-template>
 
275
      </xsl:variable>
 
276
      <xsl:if test="$testuserlevel = ''">
 
277
        <xsl:text>x</xsl:text>
 
278
      </xsl:if>
 
279
    </xsl:if>
 
280
 
 
281
    <xsl:if test="$node/@vendor != '' and $db.profile.vendor != ''">
 
282
      <xsl:variable name="testvendor">
 
283
        <xsl:call-template name="_db.profile.test.compare">
 
284
          <xsl:with-param name="attr" select="$node/@vendor"/>
 
285
          <xsl:with-param name="value" select="$db.profile.vendor"/>
 
286
        </xsl:call-template>
 
287
      </xsl:variable>
 
288
      <xsl:if test="$testvendor = ''">
 
289
        <xsl:text>x</xsl:text>
 
290
      </xsl:if>
 
291
    </xsl:if>
 
292
 
 
293
    <xsl:if test="$node/@wordsize != '' and $db.profile.wordsize != ''">
 
294
      <xsl:variable name="testwordsize">
 
295
        <xsl:call-template name="_db.profile.test.compare">
 
296
          <xsl:with-param name="attr" select="$node/@wordsize"/>
 
297
          <xsl:with-param name="value" select="$db.profile.wordsize"/>
 
298
        </xsl:call-template>
 
299
      </xsl:variable>
 
300
      <xsl:if test="$testwordsize = ''">
 
301
        <xsl:text>x</xsl:text>
 
302
      </xsl:if>
 
303
    </xsl:if>
 
304
  </xsl:variable>
 
305
 
 
306
  <xsl:if test="$testnot = ''">
 
307
    <xsl:text>true</xsl:text>
 
308
  </xsl:if>
 
309
</xsl:template>
 
310
 
 
311
<!--#* _db.profile.test.compare -->
 
312
<xsl:template name="_db.profile.test.compare">
 
313
  <xsl:param name="attr"/>
 
314
  <xsl:param name="value"/>
 
315
  <xsl:variable name="attr_" select="concat(';', $attr, ';')"/>
 
316
  <xsl:for-each select="str:split($value, ';')">
 
317
    <xsl:if test="contains($attr_, concat(';', ., ';'))">
 
318
      <xsl:text>1</xsl:text>
 
319
    </xsl:if>
 
320
  </xsl:for-each>
 
321
</xsl:template>
 
322
 
 
323
</xsl:stylesheet>