OSDN Git Service

Add Document from TortoiseSVN 15285
[tortoisegit/TortoiseGitJp.git] / doc / xsl / profile-mode.xsl
1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
2                 version="1.0">\r
3 \r
4 <!-- Copy all non-element nodes -->\r
5 <xsl:template match="@*|text()|comment()|processing-instruction()" mode="profile">\r
6   <xsl:copy/>\r
7 </xsl:template>\r
8 \r
9 <!-- Profile elements based on input parameters -->\r
10 <xsl:template match="*" mode="profile">\r
11 \r
12   <xsl:variable name="arch.content">\r
13     <xsl:if test="@arch">\r
14       <xsl:call-template name="cross.compare">\r
15         <xsl:with-param name="a" select="$profile.arch"/>\r
16         <xsl:with-param name="b" select="@arch"/>\r
17       </xsl:call-template>\r
18     </xsl:if>\r
19   </xsl:variable>\r
20   <xsl:variable name="arch.ok" select="not(@arch) or not($profile.arch) or\r
21                                        $arch.content != '' or @arch = ''"/>\r
22 \r
23   <xsl:variable name="condition.content">\r
24     <xsl:if test="@condition">\r
25       <xsl:call-template name="cross.compare">\r
26         <xsl:with-param name="a" select="$profile.condition"/>\r
27         <xsl:with-param name="b" select="@condition"/>\r
28       </xsl:call-template>\r
29     </xsl:if>\r
30   </xsl:variable>\r
31   <xsl:variable name="condition.ok" select="not(@condition) or not($profile.condition) or\r
32                                             $condition.content != '' or @condition = ''"/>\r
33 \r
34   <xsl:variable name="conformance.content">\r
35     <xsl:if test="@conformance">\r
36       <xsl:call-template name="cross.compare">\r
37         <xsl:with-param name="a" select="$profile.conformance"/>\r
38         <xsl:with-param name="b" select="@conformance"/>\r
39       </xsl:call-template>\r
40     </xsl:if>\r
41   </xsl:variable>\r
42   <xsl:variable name="conformance.ok" select="not(@conformance) or not($profile.conformance) or\r
43                                               $conformance.content != '' or @conformance = ''"/>\r
44 \r
45   <xsl:variable name="lang.content">\r
46     <xsl:if test="@lang">\r
47       <xsl:call-template name="cross.compare">\r
48         <xsl:with-param name="a" select="$profile.lang"/>\r
49         <xsl:with-param name="b" select="@lang"/>\r
50       </xsl:call-template>\r
51     </xsl:if>\r
52   </xsl:variable>\r
53   <xsl:variable name="lang.ok" select="not(@lang) or not($profile.lang) or\r
54                                        $lang.content != '' or @lang = ''"/>\r
55 \r
56   <xsl:variable name="os.content">\r
57     <xsl:if test="@os">\r
58       <xsl:call-template name="cross.compare">\r
59         <xsl:with-param name="a" select="$profile.os"/>\r
60         <xsl:with-param name="b" select="@os"/>\r
61       </xsl:call-template>\r
62     </xsl:if>\r
63   </xsl:variable>\r
64   <xsl:variable name="os.ok" select="not(@os) or not($profile.os) or\r
65                                      $os.content != '' or @os = ''"/>\r
66 \r
67   <xsl:variable name="revision.content">\r
68     <xsl:if test="@revision">\r
69       <xsl:call-template name="cross.compare">\r
70         <xsl:with-param name="a" select="$profile.revision"/>\r
71         <xsl:with-param name="b" select="@revision"/>\r
72       </xsl:call-template>\r
73     </xsl:if>\r
74   </xsl:variable>\r
75   <xsl:variable name="revision.ok" select="not(@revision) or not($profile.revision) or\r
76                                            $revision.content != '' or @revision = ''"/>\r
77 \r
78   <xsl:variable name="revisionflag.content">\r
79     <xsl:if test="@revisionflag">\r
80       <xsl:call-template name="cross.compare">\r
81         <xsl:with-param name="a" select="$profile.revisionflag"/>\r
82         <xsl:with-param name="b" select="@revisionflag"/>\r
83       </xsl:call-template>\r
84     </xsl:if>\r
85   </xsl:variable>\r
86   <xsl:variable name="revisionflag.ok" select="not(@revisionflag) or not($profile.revisionflag) or\r
87                                                $revisionflag.content != '' or @revisionflag = ''"/>\r
88 \r
89   <xsl:variable name="role.content">\r
90     <xsl:if test="@role">\r
91       <xsl:call-template name="cross.compare">\r
92         <xsl:with-param name="a" select="$profile.role"/>\r
93         <xsl:with-param name="b" select="@role"/>\r
94       </xsl:call-template>\r
95     </xsl:if>\r
96   </xsl:variable>\r
97   <xsl:variable name="role.ok" select="not(@role) or not($profile.role) or\r
98                                        $role.content != '' or @role = ''"/>\r
99 \r
100   <xsl:variable name="security.content">\r
101     <xsl:if test="@security">\r
102       <xsl:call-template name="cross.compare">\r
103         <xsl:with-param name="a" select="$profile.security"/>\r
104         <xsl:with-param name="b" select="@security"/>\r
105       </xsl:call-template>\r
106     </xsl:if>\r
107   </xsl:variable>\r
108   <xsl:variable name="security.ok" select="not(@security) or not($profile.security) or\r
109                                            $security.content != '' or @security = ''"/>\r
110 \r
111   <xsl:variable name="userlevel.content">\r
112     <xsl:if test="@userlevel">\r
113       <xsl:call-template name="cross.compare">\r
114         <xsl:with-param name="a" select="$profile.userlevel"/>\r
115         <xsl:with-param name="b" select="@userlevel"/>\r
116       </xsl:call-template>\r
117     </xsl:if>\r
118   </xsl:variable>\r
119   <xsl:variable name="userlevel.ok" select="not(@userlevel) or not($profile.userlevel) or\r
120                                             $userlevel.content != '' or @userlevel = ''"/>\r
121 \r
122   <xsl:variable name="vendor.content">\r
123     <xsl:if test="@vendor">\r
124       <xsl:call-template name="cross.compare">\r
125         <xsl:with-param name="a" select="$profile.vendor"/>\r
126         <xsl:with-param name="b" select="@vendor"/>\r
127       </xsl:call-template>\r
128     </xsl:if>\r
129   </xsl:variable>\r
130   <xsl:variable name="vendor.ok" select="not(@vendor) or not($profile.vendor) or\r
131                                          $vendor.content != '' or @vendor = ''"/>\r
132 \r
133   <xsl:variable name="attribute.content">\r
134     <xsl:if test="@*[local-name()=$profile.attribute]">\r
135       <xsl:call-template name="cross.compare">\r
136         <xsl:with-param name="a" select="$profile.value"/>\r
137         <xsl:with-param name="b" select="@*[local-name()=$profile.attribute]"/>\r
138       </xsl:call-template>\r
139     </xsl:if>\r
140   </xsl:variable>\r
141   <xsl:variable name="attribute.ok" \r
142                 select="not(@*[local-name()=$profile.attribute]) or not($profile.value) or\r
143                         $attribute.content != '' or \r
144                         @*[local-name()=$profile.attribute] = '' or not($profile.attribute)"/>\r
145 \r
146   <xsl:if test="$arch.ok and $condition.ok and $conformance.ok and $lang.ok and $os.ok \r
147                 and $revision.ok and $revisionflag.ok and $role.ok and $security.ok\r
148                 and $userlevel.ok and $vendor.ok and $attribute.ok">\r
149     <xsl:copy>\r
150       <xsl:apply-templates select="@*|node()" mode="profile"/>\r
151     </xsl:copy>\r
152   </xsl:if>\r
153 </xsl:template>\r
154 \r
155 <!-- Returns non-empty string if list in $b contains one ore more values from list $a -->\r
156 <xsl:template name="cross.compare">\r
157   <xsl:param name="a"/>\r
158   <xsl:param name="b"/>\r
159   <xsl:param name="sep" select="$profile.separator"/>\r
160   <xsl:variable name="head" select="substring-before(concat($a, $sep), $sep)"/>\r
161   <xsl:variable name="tail" select="substring-after($a, $sep)"/>\r
162   <xsl:if test="contains(concat($sep, $b, $sep), concat($sep, $head, $sep))">1</xsl:if>\r
163   <xsl:if test="$tail">\r
164     <xsl:call-template name="cross.compare">\r
165       <xsl:with-param name="a" select="$tail"/>\r
166       <xsl:with-param name="b" select="$b"/>\r
167     </xsl:call-template>\r
168   </xsl:if>\r
169 </xsl:template>\r
170 \r
171 </xsl:stylesheet>\r
172 \r