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="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"/>
36 <xsl:variable name="audience.ok"
37 select="not(@audience) or not($profile.audience) or
38 $audience.content != '' or @audience = ''"/>
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"/>
48 <xsl:variable name="condition.ok" select="not(@condition) or not($profile.condition) or
49 $condition.content != '' or @condition = ''"/>
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"/>
59 <xsl:variable name="conformance.ok" select="not(@conformance) or not($profile.conformance) or
60 $conformance.content != '' or @conformance = ''"/>
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]"/>
70 <xsl:variable name="lang.ok" select="not(@lang | @xml:lang) or not($profile.lang) or
71 $lang.content != '' or @lang = '' or @xml:lang = ''"/>
73 <xsl:variable name="os.content">
75 <xsl:call-template name="cross.compare">
76 <xsl:with-param name="a" select="$profile.os"/>
77 <xsl:with-param name="b" select="@os"/>
81 <xsl:variable name="os.ok" select="not(@os) or not($profile.os) or
82 $os.content != '' or @os = ''"/>
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"/>
92 <xsl:variable name="revision.ok" select="not(@revision) or not($profile.revision) or
93 $revision.content != '' or @revision = ''"/>
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"/>
103 <xsl:variable name="revisionflag.ok" select="not(@revisionflag) or not($profile.revisionflag) or
104 $revisionflag.content != '' or @revisionflag = ''"/>
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"/>
114 <xsl:variable name="role.ok" select="not(@role) or not($profile.role) or
115 $role.content != '' or @role = ''"/>
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"/>
125 <xsl:variable name="security.ok" select="not(@security) or not($profile.security) or
126 $security.content != '' or @security = ''"/>
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"/>
136 <xsl:variable name="status.ok" select="not(@status) or not($profile.status) or
137 $status.content != '' or @status = ''"/>
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"/>
147 <xsl:variable name="userlevel.ok" select="not(@userlevel) or not($profile.userlevel) or
148 $userlevel.content != '' or @userlevel = ''"/>
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"/>
158 <xsl:variable name="vendor.ok" select="not(@vendor) or not($profile.vendor) or
159 $vendor.content != '' or @vendor = ''"/>
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"/>
169 <xsl:variable name="wordsize.ok"
170 select="not(@wordsize) or not($profile.wordsize) or
171 $wordsize.content != '' or @wordsize = ''"/>
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]"/>
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)"/>
187 <xsl:if test="$arch.ok and
203 <xsl:apply-templates mode="profile" select="@*"/>
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)"/>
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"/>
217 <xsl:apply-templates select="node()" mode="profile"/>
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"/>