| 1 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 2 |
version="1.0"> |
|---|
| 3 |
|
|---|
| 4 |
<!-- Copy all non-element nodes --> |
|---|
| 5 |
<xsl:template match="@*|text()|comment()|processing-instruction()" mode="profile"> |
|---|
| 6 |
<xsl:copy/> |
|---|
| 7 |
</xsl:template> |
|---|
| 8 |
|
|---|
| 9 |
<!-- Profile elements based on input parameters --> |
|---|
| 10 |
<xsl:template match="*" mode="profile"> |
|---|
| 11 |
|
|---|
| 12 |
<xsl:variable name="arch.content"> |
|---|
| 13 |
<xsl:if test="@arch"> |
|---|
| 14 |
<xsl:call-template name="cross.compare"> |
|---|
| 15 |
<xsl:with-param name="a" select="$profile.arch"/> |
|---|
| 16 |
<xsl:with-param name="b" select="@arch"/> |
|---|
| 17 |
</xsl:call-template> |
|---|
| 18 |
</xsl:if> |
|---|
| 19 |
</xsl:variable> |
|---|
| 20 |
<xsl:variable name="arch.ok" select="not(@arch) or not($profile.arch) or |
|---|
| 21 |
$arch.content != '' or @arch = ''"/> |
|---|
| 22 |
|
|---|
| 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"/> |
|---|
| 28 |
</xsl:call-template> |
|---|
| 29 |
</xsl:if> |
|---|
| 30 |
</xsl:variable> |
|---|
| 31 |
<xsl:variable name="condition.ok" select="not(@condition) or not($profile.condition) or |
|---|
| 32 |
$condition.content != '' or @condition = ''"/> |
|---|
| 33 |
|
|---|
| 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"/> |
|---|
| 39 |
</xsl:call-template> |
|---|
| 40 |
</xsl:if> |
|---|
| 41 |
</xsl:variable> |
|---|
| 42 |
<xsl:variable name="conformance.ok" select="not(@conformance) or not($profile.conformance) or |
|---|
| 43 |
$conformance.content != '' or @conformance = ''"/> |
|---|
| 44 |
|
|---|
| 45 |
<xsl:variable name="lang.content"> |
|---|
| 46 |
<xsl:if test="@lang"> |
|---|
| 47 |
<xsl:call-template name="cross.compare"> |
|---|
| 48 |
<xsl:with-param name="a" select="$profile.lang"/> |
|---|
| 49 |
<xsl:with-param name="b" select="@lang"/> |
|---|
| 50 |
</xsl:call-template> |
|---|
| 51 |
</xsl:if> |
|---|
| 52 |
</xsl:variable> |
|---|
| 53 |
<xsl:variable name="lang.ok" select="not(@lang) or not($profile.lang) or |
|---|
| 54 |
$lang.content != '' or @lang = ''"/> |
|---|
| 55 |
|
|---|
| 56 |
<xsl:variable name="os.content"> |
|---|
| 57 |
<xsl:if test="@os"> |
|---|
| 58 |
<xsl:call-template name="cross.compare"> |
|---|
| 59 |
<xsl:with-param name="a" select="$profile.os"/> |
|---|
| 60 |
<xsl:with-param name="b" select="@os"/> |
|---|
| 61 |
</xsl:call-template> |
|---|
| 62 |
</xsl:if> |
|---|
| 63 |
</xsl:variable> |
|---|
| 64 |
<xsl:variable name="os.ok" select="not(@os) or not($profile.os) or |
|---|
| 65 |
$os.content != '' or @os = ''"/> |
|---|
| 66 |
|
|---|
| 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"/> |
|---|
| 72 |
</xsl:call-template> |
|---|
| 73 |
</xsl:if> |
|---|
| 74 |
</xsl:variable> |
|---|
| 75 |
<xsl:variable name="revision.ok" select="not(@revision) or not($profile.revision) or |
|---|
| 76 |
$revision.content != '' or @revision = ''"/> |
|---|
| 77 |
|
|---|
| 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"/> |
|---|
| 83 |
</xsl:call-template> |
|---|
| 84 |
</xsl:if> |
|---|
| 85 |
</xsl:variable> |
|---|
| 86 |
<xsl:variable name="revisionflag.ok" select="not(@revisionflag) or not($profile.revisionflag) or |
|---|
| 87 |
$revisionflag.content != '' or @revisionflag = ''"/> |
|---|
| 88 |
|
|---|
| 89 |
<xsl:variable name="role.content"> |
|---|
| 90 |
<xsl:if test="@role"> |
|---|
| 91 |
<xsl:call-template name="cross.compare"> |
|---|
| 92 |
<xsl:with-param name="a" select="$profile.role"/> |
|---|
| 93 |
<xsl:with-param name="b" select="@role"/> |
|---|
| 94 |
</xsl:call-template> |
|---|
| 95 |
</xsl:if> |
|---|
| 96 |
</xsl:variable> |
|---|
| 97 |
<xsl:variable name="role.ok" select="not(@role) or not($profile.role) or |
|---|
| 98 |
$role.content != '' or @role = ''"/> |
|---|
| 99 |
|
|---|
| 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"/> |
|---|
| 105 |
</xsl:call-template> |
|---|
| 106 |
</xsl:if> |
|---|
| 107 |
</xsl:variable> |
|---|
| 108 |
<xsl:variable name="security.ok" select="not(@security) or not($profile.security) or |
|---|
| 109 |
$security.content != '' or @security = ''"/> |
|---|
| 110 |
|
|---|
| 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"/> |
|---|
| 116 |
</xsl:call-template> |
|---|
| 117 |
</xsl:if> |
|---|
| 118 |
</xsl:variable> |
|---|
| 119 |
<xsl:variable name="userlevel.ok" select="not(@userlevel) or not($profile.userlevel) or |
|---|
| 120 |
$userlevel.content != '' or @userlevel = ''"/> |
|---|
| 121 |
|
|---|
| 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"/> |
|---|
| 127 |
</xsl:call-template> |
|---|
| 128 |
</xsl:if> |
|---|
| 129 |
</xsl:variable> |
|---|
| 130 |
<xsl:variable name="vendor.ok" select="not(@vendor) or not($profile.vendor) or |
|---|
| 131 |
$vendor.content != '' or @vendor = ''"/> |
|---|
| 132 |
|
|---|
| 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]"/> |
|---|
| 138 |
</xsl:call-template> |
|---|
| 139 |
</xsl:if> |
|---|
| 140 |
</xsl:variable> |
|---|
| 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)"/> |
|---|
| 145 |
|
|---|
| 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"> |
|---|
| 149 |
<xsl:copy> |
|---|
| 150 |
<xsl:apply-templates select="@*|node()" mode="profile"/> |
|---|
| 151 |
</xsl:copy> |
|---|
| 152 |
</xsl:if> |
|---|
| 153 |
</xsl:template> |
|---|
| 154 |
|
|---|
| 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"/> |
|---|
| 167 |
</xsl:call-template> |
|---|
| 168 |
</xsl:if> |
|---|
| 169 |
</xsl:template> |
|---|
| 170 |
|
|---|
| 171 |
</xsl:stylesheet> |
|---|
| 172 |
|
|---|