1 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
2 xmlns:
saxon=
"http://icl.com/saxon"
3 exclude-result-prefixes=
"saxon"
6 <!-- Should be base URI for imagedata and so on fixed? -->
7 <xsl:param name=
"profile.baseuri.fixup" select=
"true()"/>
9 <!-- Copy all non-element nodes -->
10 <xsl:template match=
"@*|text()|comment()|processing-instruction()" mode=
"profile">
14 <!-- Profile elements based on input parameters -->
15 <xsl:template match=
"*" mode=
"profile">
17 <xsl:variable name=
"arch.content">
19 <xsl:call-template name=
"cross.compare">
20 <xsl:with-param name=
"a" select=
"$profile.arch"/>
21 <xsl:with-param name=
"b" select=
"@arch"/>
25 <xsl:variable name=
"arch.ok" select=
"not(@arch) or not($profile.arch) or
26 $arch.content != '' or @arch = ''"/>
28 <xsl:variable name=
"condition.content">
29 <xsl:if test=
"@condition">
30 <xsl:call-template name=
"cross.compare">
31 <xsl:with-param name=
"a" select=
"$profile.condition"/>
32 <xsl:with-param name=
"b" select=
"@condition"/>
36 <xsl:variable name=
"condition.ok" select=
"not(@condition) or not($profile.condition) or
37 $condition.content != '' or @condition = ''"/>
39 <xsl:variable name=
"conformance.content">
40 <xsl:if test=
"@conformance">
41 <xsl:call-template name=
"cross.compare">
42 <xsl:with-param name=
"a" select=
"$profile.conformance"/>
43 <xsl:with-param name=
"b" select=
"@conformance"/>
47 <xsl:variable name=
"conformance.ok" select=
"not(@conformance) or not($profile.conformance) or
48 $conformance.content != '' or @conformance = ''"/>
50 <xsl:variable name=
"lang.content">
51 <xsl:if test=
"@lang | @xml:lang">
52 <xsl:call-template name=
"cross.compare">
53 <xsl:with-param name=
"a" select=
"$profile.lang"/>
54 <xsl:with-param name=
"b" select=
"(@lang | @xml:lang)[1]"/>
58 <xsl:variable name=
"lang.ok" select=
"not(@lang | @xml:lang) or not($profile.lang) or
59 $lang.content != '' or @lang = '' or @xml:lang = ''"/>
61 <xsl:variable name=
"os.content">
63 <xsl:call-template name=
"cross.compare">
64 <xsl:with-param name=
"a" select=
"$profile.os"/>
65 <xsl:with-param name=
"b" select=
"@os"/>
69 <xsl:variable name=
"os.ok" select=
"not(@os) or not($profile.os) or
70 $os.content != '' or @os = ''"/>
72 <xsl:variable name=
"revision.content">
73 <xsl:if test=
"@revision">
74 <xsl:call-template name=
"cross.compare">
75 <xsl:with-param name=
"a" select=
"$profile.revision"/>
76 <xsl:with-param name=
"b" select=
"@revision"/>
80 <xsl:variable name=
"revision.ok" select=
"not(@revision) or not($profile.revision) or
81 $revision.content != '' or @revision = ''"/>
83 <xsl:variable name=
"revisionflag.content">
84 <xsl:if test=
"@revisionflag">
85 <xsl:call-template name=
"cross.compare">
86 <xsl:with-param name=
"a" select=
"$profile.revisionflag"/>
87 <xsl:with-param name=
"b" select=
"@revisionflag"/>
91 <xsl:variable name=
"revisionflag.ok" select=
"not(@revisionflag) or not($profile.revisionflag) or
92 $revisionflag.content != '' or @revisionflag = ''"/>
94 <xsl:variable name=
"role.content">
96 <xsl:call-template name=
"cross.compare">
97 <xsl:with-param name=
"a" select=
"$profile.role"/>
98 <xsl:with-param name=
"b" select=
"@role"/>
102 <xsl:variable name=
"role.ok" select=
"not(@role) or not($profile.role) or
103 $role.content != '' or @role = ''"/>
105 <xsl:variable name=
"security.content">
106 <xsl:if test=
"@security">
107 <xsl:call-template name=
"cross.compare">
108 <xsl:with-param name=
"a" select=
"$profile.security"/>
109 <xsl:with-param name=
"b" select=
"@security"/>
113 <xsl:variable name=
"security.ok" select=
"not(@security) or not($profile.security) or
114 $security.content != '' or @security = ''"/>
116 <xsl:variable name=
"status.content">
117 <xsl:if test=
"@status">
118 <xsl:call-template name=
"cross.compare">
119 <xsl:with-param name=
"a" select=
"$profile.status"/>
120 <xsl:with-param name=
"b" select=
"@status"/>
124 <xsl:variable name=
"status.ok" select=
"not(@status) or not($profile.status) or
125 $status.content != '' or @status = ''"/>
127 <xsl:variable name=
"userlevel.content">
128 <xsl:if test=
"@userlevel">
129 <xsl:call-template name=
"cross.compare">
130 <xsl:with-param name=
"a" select=
"$profile.userlevel"/>
131 <xsl:with-param name=
"b" select=
"@userlevel"/>
135 <xsl:variable name=
"userlevel.ok" select=
"not(@userlevel) or not($profile.userlevel) or
136 $userlevel.content != '' or @userlevel = ''"/>
138 <xsl:variable name=
"vendor.content">
139 <xsl:if test=
"@vendor">
140 <xsl:call-template name=
"cross.compare">
141 <xsl:with-param name=
"a" select=
"$profile.vendor"/>
142 <xsl:with-param name=
"b" select=
"@vendor"/>
146 <xsl:variable name=
"vendor.ok" select=
"not(@vendor) or not($profile.vendor) or
147 $vendor.content != '' or @vendor = ''"/>
149 <xsl:variable name=
"attribute.content">
150 <xsl:if test=
"@*[local-name()=$profile.attribute]">
151 <xsl:call-template name=
"cross.compare">
152 <xsl:with-param name=
"a" select=
"$profile.value"/>
153 <xsl:with-param name=
"b" select=
"@*[local-name()=$profile.attribute]"/>
157 <xsl:variable name=
"attribute.ok"
158 select=
"not(@*[local-name()=$profile.attribute]) or not($profile.value) or
159 $attribute.content != '' or
160 @*[local-name()=$profile.attribute] = '' or not($profile.attribute)"/>
162 <xsl:if test=
"$arch.ok and $condition.ok and $conformance.ok and $lang.ok and $os.ok
163 and $revision.ok and $revisionflag.ok and $role.ok and $security.ok
164 and $status.ok and $userlevel.ok and $vendor.ok and $attribute.ok">
166 <xsl:copy-of select=
"@*"/>
168 <!-- Entity references must be replaced with filereferences for temporary tree -->
169 <xsl:if test=
"@entityref and $profile.baseuri.fixup">
170 <xsl:attribute name=
"fileref">
171 <xsl:value-of select=
"unparsed-entity-uri(@entityref)"/>
175 <!-- xml:base is eventually added to the root element -->
176 <xsl:if test=
"not(../..) and $profile.baseuri.fixup">
177 <xsl:call-template name=
"add-xml-base"/>
180 <xsl:apply-templates select=
"node()" mode=
"profile"/>
185 <!-- Returns non-empty string if list in $b contains one ore more values from list $a -->
186 <xsl:template name=
"cross.compare">
187 <xsl:param name=
"a"/>
188 <xsl:param name=
"b"/>
189 <xsl:param name=
"sep" select=
"$profile.separator"/>
190 <xsl:variable name=
"head" select=
"substring-before(concat($a, $sep), $sep)"/>
191 <xsl:variable name=
"tail" select=
"substring-after($a, $sep)"/>
192 <xsl:if test=
"contains(concat($sep, $b, $sep), concat($sep, $head, $sep))">1</xsl:if>
193 <xsl:if test=
"$tail">
194 <xsl:call-template name=
"cross.compare">
195 <xsl:with-param name=
"a" select=
"$tail"/>
196 <xsl:with-param name=
"b" select=
"$b"/>