1 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
4 <!-- Copy all non-element nodes -->
5 <xsl:template match=
"@*|text()|comment()|processing-instruction()" mode=
"profile">
9 <!-- Profile elements based on input parameters -->
10 <xsl:template match=
"*" mode=
"profile">
12 <xsl:variable name=
"arch.content">
14 <xsl:call-template name=
"cross.compare">
15 <xsl:with-param name=
"a" select=
"$profile.arch"/>
16 <xsl:with-param name=
"b" select=
"@arch"/>
20 <xsl:variable name=
"arch.ok" select=
"not(@arch) or not($profile.arch) or
21 $arch.content != '' or @arch = ''"/>
23 <xsl:variable name=
"condition.content">
24 <xsl:if test=
"@condition">
25 <xsl:call-template name=
"cross.compare">
26 <xsl:with-param name=
"a" select=
"$profile.condition"/>
27 <xsl:with-param name=
"b" select=
"@condition"/>
31 <xsl:variable name=
"condition.ok" select=
"not(@condition) or not($profile.condition) or
32 $condition.content != '' or @condition = ''"/>
34 <xsl:variable name=
"conformance.content">
35 <xsl:if test=
"@conformance">
36 <xsl:call-template name=
"cross.compare">
37 <xsl:with-param name=
"a" select=
"$profile.conformance"/>
38 <xsl:with-param name=
"b" select=
"@conformance"/>
42 <xsl:variable name=
"conformance.ok" select=
"not(@conformance) or not($profile.conformance) or
43 $conformance.content != '' or @conformance = ''"/>
45 <xsl:variable name=
"lang.content">
47 <xsl:call-template name=
"cross.compare">
48 <xsl:with-param name=
"a" select=
"$profile.lang"/>
49 <xsl:with-param name=
"b" select=
"@lang"/>
53 <xsl:variable name=
"lang.ok" select=
"not(@lang) or not($profile.lang) or
54 $lang.content != '' or @lang = ''"/>
56 <xsl:variable name=
"os.content">
58 <xsl:call-template name=
"cross.compare">
59 <xsl:with-param name=
"a" select=
"$profile.os"/>
60 <xsl:with-param name=
"b" select=
"@os"/>
64 <xsl:variable name=
"os.ok" select=
"not(@os) or not($profile.os) or
65 $os.content != '' or @os = ''"/>
67 <xsl:variable name=
"revision.content">
68 <xsl:if test=
"@revision">
69 <xsl:call-template name=
"cross.compare">
70 <xsl:with-param name=
"a" select=
"$profile.revision"/>
71 <xsl:with-param name=
"b" select=
"@revision"/>
75 <xsl:variable name=
"revision.ok" select=
"not(@revision) or not($profile.revision) or
76 $revision.content != '' or @revision = ''"/>
78 <xsl:variable name=
"revisionflag.content">
79 <xsl:if test=
"@revisionflag">
80 <xsl:call-template name=
"cross.compare">
81 <xsl:with-param name=
"a" select=
"$profile.revisionflag"/>
82 <xsl:with-param name=
"b" select=
"@revisionflag"/>
86 <xsl:variable name=
"revisionflag.ok" select=
"not(@revisionflag) or not($profile.revisionflag) or
87 $revisionflag.content != '' or @revisionflag = ''"/>
89 <xsl:variable name=
"role.content">
91 <xsl:call-template name=
"cross.compare">
92 <xsl:with-param name=
"a" select=
"$profile.role"/>
93 <xsl:with-param name=
"b" select=
"@role"/>
97 <xsl:variable name=
"role.ok" select=
"not(@role) or not($profile.role) or
98 $role.content != '' or @role = ''"/>
100 <xsl:variable name=
"security.content">
101 <xsl:if test=
"@security">
102 <xsl:call-template name=
"cross.compare">
103 <xsl:with-param name=
"a" select=
"$profile.security"/>
104 <xsl:with-param name=
"b" select=
"@security"/>
108 <xsl:variable name=
"security.ok" select=
"not(@security) or not($profile.security) or
109 $security.content != '' or @security = ''"/>
111 <xsl:variable name=
"userlevel.content">
112 <xsl:if test=
"@userlevel">
113 <xsl:call-template name=
"cross.compare">
114 <xsl:with-param name=
"a" select=
"$profile.userlevel"/>
115 <xsl:with-param name=
"b" select=
"@userlevel"/>
119 <xsl:variable name=
"userlevel.ok" select=
"not(@userlevel) or not($profile.userlevel) or
120 $userlevel.content != '' or @userlevel = ''"/>
122 <xsl:variable name=
"vendor.content">
123 <xsl:if test=
"@vendor">
124 <xsl:call-template name=
"cross.compare">
125 <xsl:with-param name=
"a" select=
"$profile.vendor"/>
126 <xsl:with-param name=
"b" select=
"@vendor"/>
130 <xsl:variable name=
"vendor.ok" select=
"not(@vendor) or not($profile.vendor) or
131 $vendor.content != '' or @vendor = ''"/>
133 <xsl:variable name=
"attribute.content">
134 <xsl:if test=
"@*[local-name()=$profile.attribute]">
135 <xsl:call-template name=
"cross.compare">
136 <xsl:with-param name=
"a" select=
"$profile.value"/>
137 <xsl:with-param name=
"b" select=
"@*[local-name()=$profile.attribute]"/>
141 <xsl:variable name=
"attribute.ok"
142 select=
"not(@*[local-name()=$profile.attribute]) or not($profile.value) or
143 $attribute.content != '' or
144 @*[local-name()=$profile.attribute] = '' or not($profile.attribute)"/>
146 <xsl:if test=
"$arch.ok and $condition.ok and $conformance.ok and $lang.ok and $os.ok
147 and $revision.ok and $revisionflag.ok and $role.ok and $security.ok
148 and $userlevel.ok and $vendor.ok and $attribute.ok">
150 <xsl:apply-templates select=
"@*|node()" mode=
"profile"/>
155 <!-- Returns non-empty string if list in $b contains one ore more values from list $a -->
156 <xsl:template name=
"cross.compare">
157 <xsl:param name=
"a"/>
158 <xsl:param name=
"b"/>
159 <xsl:param name=
"sep" select=
"$profile.separator"/>
160 <xsl:variable name=
"head" select=
"substring-before(concat($a, $sep), $sep)"/>
161 <xsl:variable name=
"tail" select=
"substring-after($a, $sep)"/>
162 <xsl:if test=
"contains(concat($sep, $b, $sep), concat($sep, $head, $sep))">1</xsl:if>
163 <xsl:if test=
"$tail">
164 <xsl:call-template name=
"cross.compare">
165 <xsl:with-param name=
"a" select=
"$tail"/>
166 <xsl:with-param name=
"b" select=
"$b"/>