| 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, see <http://www.gnu.org/licenses/>. |
| 15 |
--> |
| 16 |
|
| 17 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 18 |
xmlns:str="http://exslt.org/strings" |
| 19 |
exclude-result-prefixes="str" |
| 20 |
version="1.0"> |
| 21 |
|
| 22 |
<!--!!========================================================================== |
| 23 |
DocBook Profiling |
| 24 |
Support for DocBook effectivity attributes |
| 25 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 26 |
|
| 27 |
This stylesheet contains utilities for handling conditional processing |
| 28 |
in DocBook documents. |
| 29 |
--> |
| 30 |
|
| 31 |
|
| 32 |
<!--@@========================================================================== |
| 33 |
db.profile.arch |
| 34 |
The list of architectures for conditional processing. |
| 35 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 36 |
|
| 37 |
This parameter takes a semicolon-separated list of values to match against the |
| 38 |
`arch` attribute for conditional processing. |
| 39 |
--> |
| 40 |
<xsl:param name="db.profile.arch" select="''"/> |
| 41 |
|
| 42 |
|
| 43 |
<!--@@========================================================================== |
| 44 |
db.profile.audience |
| 45 |
The list of audiences for conditional processing. |
| 46 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 47 |
|
| 48 |
This parameter takes a semicolon-separated list of values to match against the |
| 49 |
`audience` attribute for conditional processing. |
| 50 |
--> |
| 51 |
<xsl:param name="db.profile.audience" select="''"/> |
| 52 |
|
| 53 |
|
| 54 |
<!--@@========================================================================== |
| 55 |
db.profile.condition |
| 56 |
The list of application-specific conditions for conditional processing. |
| 57 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 58 |
|
| 59 |
This parameter takes a semicolon-separated list of values to match against the |
| 60 |
`condition` attribute for conditional processing. |
| 61 |
--> |
| 62 |
<xsl:param name="db.profile.condition" select="''"/> |
| 63 |
|
| 64 |
|
| 65 |
<!--@@========================================================================== |
| 66 |
db.profile.conformance |
| 67 |
The list of conformance characteristics for conditional processing. |
| 68 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 69 |
|
| 70 |
This parameter takes a semicolon-separated list of values to match against the |
| 71 |
`conformance` attribute for conditional processing. |
| 72 |
--> |
| 73 |
<xsl:param name="db.profile.conformance" select="''"/> |
| 74 |
|
| 75 |
|
| 76 |
<!--@@========================================================================== |
| 77 |
db.profile.os |
| 78 |
The list of operating systems for conditional processing. |
| 79 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 80 |
|
| 81 |
This parameter takes a semicolon-separated list of values to match against the |
| 82 |
`os` attribute for conditional processing. |
| 83 |
--> |
| 84 |
<xsl:param name="db.profile.os" select="''"/> |
| 85 |
|
| 86 |
|
| 87 |
<!--@@========================================================================== |
| 88 |
db.profile.outputformat |
| 89 |
The list of output formats for conditional processing. |
| 90 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 91 |
|
| 92 |
This parameter takes a semicolon-separated list of values to match against the |
| 93 |
`outputformat` attribute for conditional processing. |
| 94 |
--> |
| 95 |
<xsl:param name="db.profile.outputformat" select="''"/> |
| 96 |
|
| 97 |
|
| 98 |
<!--@@========================================================================== |
| 99 |
db.profile.revision |
| 100 |
The list of editorial revisions for conditional processing. |
| 101 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 102 |
|
| 103 |
This parameter takes a semicolon-separated list of values to match against the |
| 104 |
`revision` attribute for conditional processing. |
| 105 |
--> |
| 106 |
<xsl:param name="db.profile.revision" select="''"/> |
| 107 |
|
| 108 |
|
| 109 |
<!--@@========================================================================== |
| 110 |
db.profile.security |
| 111 |
The list of security levels for conditional processing. |
| 112 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 113 |
|
| 114 |
This parameter takes a semicolon-separated list of values to match against the |
| 115 |
`security` attribute for conditional processing. |
| 116 |
--> |
| 117 |
<xsl:param name="db.profile.security" select="''"/> |
| 118 |
|
| 119 |
|
| 120 |
<!--@@========================================================================== |
| 121 |
db.profile.userlevel |
| 122 |
The list of user experience levels for conditional processing. |
| 123 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 124 |
|
| 125 |
This parameter takes a semicolon-separated list of values to match against the |
| 126 |
`userlevel` attribute for conditional processing. |
| 127 |
--> |
| 128 |
<xsl:param name="db.profile.userlevel" select="''"/> |
| 129 |
|
| 130 |
|
| 131 |
<!--@@========================================================================== |
| 132 |
db.profile.vendor |
| 133 |
The list of vendors for conditional processing. |
| 134 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 135 |
|
| 136 |
This parameter takes a semicolon-separated list of values to match against the |
| 137 |
`vendor` attribute for conditional processing. |
| 138 |
--> |
| 139 |
<xsl:param name="db.profile.vendor" select="''"/> |
| 140 |
|
| 141 |
|
| 142 |
<!--@@========================================================================== |
| 143 |
db.profile.wordsize |
| 144 |
The list of word sizes for conditional processing. |
| 145 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 146 |
|
| 147 |
This parameter takes a semicolon-separated list of values to match against the |
| 148 |
`wordsize` attribute for conditional processing. |
| 149 |
--> |
| 150 |
<xsl:param name="db.profile.wordsize" select="''"/> |
| 151 |
|
| 152 |
|
| 153 |
<!--**========================================================================== |
| 154 |
db.profile.test |
| 155 |
Test if an element should be shown based on profiling attributes. |
| 156 |
@revision[version=3.10 date=2013-08-12 status=final] |
| 157 |
|
| 158 |
[xsl:params] |
| 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> |