xref: /aosp_15_r20/external/apache-xml/test/tests/extensions/library/libraryNodeset05.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
3                xmlns:ex="http://xml.apache.org/xalan"
4                extension-element-prefixes="ex">
5
6  <!-- FileName: libraryNodeset05 -->
7  <!-- Document: http://www.w3.org/TR/xslt -->
8  <!-- DocVersion: 19991116 -->
9  <!-- Section: 11.4 -->
10  <!-- Creator: Joe Kesselman -->
11  <!-- Purpose: Ensure that applying axes onto nodeset of global RTF gets the right one. -->
12
13<xsl:output method="xml" indent="no" encoding="UTF-8"/>
14
15<xsl:variable name="top1">
16<t1-far-north>
17  <t1-north>
18    <t1-near-north>
19      <t1-far-west/>
20      <t1-west/>
21      <t1-near-west/>
22      <center center-attr-1="c1" xmlns:n="http://example.com">Wrong variable, can you dig it?
23        <t1-near-south>
24          <t1-south>
25            <t1-far-south/>
26          </t1-south>
27        </t1-near-south>
28      </center>
29      <t1-near-east/>
30      <t1-east/>
31      <t1-far-east/>
32    </t1-near-north>
33  </t1-north>
34</t1-far-north>
35</xsl:variable>
36
37<xsl:variable name="top2">
38<t2-far-north>
39  <t2-north>
40    <t2-near-north>
41      <t2-far-west/>
42      <t2-west/>
43      <t2-near-west/>
44      <center center-attr-1="c2" xmlns:n="http://example.com">Dig we must!
45        <t2-near-south>
46          <t2-south>
47            <t2-far-south/>
48          </t2-south>
49        </t2-near-south>
50      </center>
51      <t2-near-east/>
52      <t2-east/>
53      <t2-far-east/>
54    </t2-near-north>
55  </t2-north>
56</t2-far-north>
57</xsl:variable>
58
59<xsl:template match="/">
60  <out>
61    <!-- First, force evaluation of each variable -->
62    <junk>
63      <xsl:text>$top1 summary: </xsl:text>
64      <xsl:value-of select="$top1"/>
65      <xsl:text>
66</xsl:text>
67      <xsl:text>$top2 summary: </xsl:text>
68      <xsl:value-of select="$top2"/>
69    </junk>
70    <xsl:text>
71</xsl:text>
72
73    <xsl:text>The center nodes in $top2 are </xsl:text>
74    <xsl:for-each select="ex:nodeset($top2)//center">
75      <xsl:value-of select="name(.)"/>
76      <xsl:text>,</xsl:text>
77    </xsl:for-each>
78    <xsl:text>
79
80</xsl:text>
81
82    <xsl:text>W01: center/child::* nodes in $top2 are </xsl:text>
83    <xsl:for-each select="ex:nodeset($top2)//center/child::*">
84      <xsl:value-of select="name(.)"/>
85      <xsl:text>,</xsl:text>
86    </xsl:for-each>
87    <xsl:text>
88</xsl:text>
89
90    <xsl:text>W02: center/descendant::* nodes in $top2 are </xsl:text>
91    <xsl:for-each select="ex:nodeset($top2)//center/descendant::*">
92      <xsl:value-of select="name(.)"/>
93      <xsl:text>,</xsl:text>
94    </xsl:for-each>
95    <xsl:text>
96</xsl:text>
97
98    <xsl:text>W03: center/parent::* nodes in $top2 are </xsl:text>
99    <xsl:for-each select="ex:nodeset($top2)//center/parent::*">
100      <xsl:value-of select="name(.)"/>
101      <xsl:text>,</xsl:text>
102    </xsl:for-each>
103    <xsl:text>
104</xsl:text>
105
106    <xsl:text>W04: center/ancestor::* nodes in $top2 are </xsl:text>
107    <xsl:for-each select="ex:nodeset($top2)//center/ancestor::*">
108      <xsl:value-of select="name(.)"/>
109      <xsl:text>,</xsl:text>
110    </xsl:for-each>
111    <xsl:text>
112</xsl:text>
113
114    <xsl:text>W05: center/following-sibling::* nodes in $top2 are </xsl:text>
115    <xsl:for-each select="ex:nodeset($top2)//center/following-sibling::*">
116      <xsl:value-of select="name(.)"/>
117      <xsl:text>,</xsl:text>
118    </xsl:for-each>
119    <xsl:text>
120</xsl:text>
121
122    <xsl:text>W06: center/preceding-sibling::* nodes in $top2 are </xsl:text>
123    <xsl:for-each select="ex:nodeset($top2)//center/preceding-sibling::*">
124      <xsl:value-of select="name(.)"/>
125      <xsl:text>,</xsl:text>
126    </xsl:for-each>
127    <xsl:text>
128</xsl:text>
129
130    <xsl:text>W07: center/following::* nodes in $top2 are </xsl:text>
131    <xsl:for-each select="ex:nodeset($top2)//center/following::*">
132      <xsl:value-of select="name(.)"/>
133      <xsl:text>,</xsl:text>
134    </xsl:for-each>
135    <xsl:text>
136</xsl:text>
137
138    <xsl:text>W08: center/preceding::* nodes in $top2 are </xsl:text>
139    <xsl:for-each select="ex:nodeset($top2)//center/preceding::*">
140      <xsl:value-of select="name(.)"/>
141      <xsl:text>,</xsl:text>
142    </xsl:for-each>
143    <xsl:text>
144</xsl:text>
145
146    <xsl:text>W09: center/attribute::* nodes in $top2 are </xsl:text>
147    <xsl:for-each select="ex:nodeset($top2)//center/attribute::*">
148      <xsl:value-of select="name(.)"/>
149      <xsl:text>,</xsl:text>
150    </xsl:for-each>
151    <xsl:text>
152</xsl:text>
153
154    <xsl:text>W10: center/namespace::* nodes in $top2 are </xsl:text>
155    <xsl:for-each select="ex:nodeset($top2)//center/namespace::*">
156      <xsl:value-of select="name(.)"/>
157      <xsl:text>,</xsl:text>
158    </xsl:for-each>
159    <xsl:text>
160</xsl:text>
161
162    <xsl:text>W11: center/self::* nodes in $top2 are </xsl:text>
163    <xsl:for-each select="ex:nodeset($top2)//center/self::*">
164      <xsl:value-of select="name(.)"/>
165      <xsl:text>,</xsl:text>
166    </xsl:for-each>
167    <xsl:text>
168</xsl:text>
169
170    <xsl:text>W12: center/descendant-or-self::* nodes in $top2 are </xsl:text>
171    <xsl:for-each select="ex:nodeset($top2)//center/descendant-or-self::*">
172      <xsl:value-of select="name(.)"/>
173      <xsl:text>,</xsl:text>
174    </xsl:for-each>
175    <xsl:text>
176</xsl:text>
177
178    <xsl:text>W13: center/ancestor-or-self::* nodes in $top2 are </xsl:text>
179    <xsl:for-each select="ex:nodeset($top2)//center/ancestor-or-self::*">
180      <xsl:value-of select="name(.)"/>
181      <xsl:text>,</xsl:text>
182    </xsl:for-each>
183    <xsl:text>
184
185</xsl:text>
186    <!-- Above was wildcard, now use name tests -->
187    <xsl:text>N01: center/child::t2-near-south nodes in $top2 are </xsl:text>
188    <xsl:for-each select="ex:nodeset($top2)//center/child::t2-near-south">
189      <xsl:value-of select="name(.)"/>
190      <xsl:text>,</xsl:text>
191    </xsl:for-each>
192    <xsl:text>
193</xsl:text>
194
195    <xsl:text>N02: center/descendant::t2-south nodes in $top2 are </xsl:text>
196    <xsl:for-each select="ex:nodeset($top2)//center/descendant::t2-south">
197      <xsl:value-of select="name(.)"/>
198      <xsl:text>,</xsl:text>
199    </xsl:for-each>
200    <xsl:text>
201</xsl:text>
202
203    <xsl:text>N03: center/parent::t2-near-north nodes in $top2 are </xsl:text>
204    <xsl:for-each select="ex:nodeset($top2)//center/parent::t2-near-north">
205      <xsl:value-of select="name(.)"/>
206      <xsl:text>,</xsl:text>
207    </xsl:for-each>
208    <xsl:text>
209</xsl:text>
210
211    <xsl:text>N04: center/ancestor::t2-north nodes in $top2 are </xsl:text>
212    <xsl:for-each select="ex:nodeset($top2)//center/ancestor::t2-north">
213      <xsl:value-of select="name(.)"/>
214      <xsl:text>,</xsl:text>
215    </xsl:for-each>
216    <xsl:text>
217</xsl:text>
218
219    <xsl:text>N05: center/following-sibling::t2-east nodes in $top2 are </xsl:text>
220    <xsl:for-each select="ex:nodeset($top2)//center/following-sibling::t2-east">
221      <xsl:value-of select="name(.)"/>
222      <xsl:text>,</xsl:text>
223    </xsl:for-each>
224    <xsl:text>
225</xsl:text>
226
227    <xsl:text>N06: center/preceding-sibling::t2-west nodes in $top2 are </xsl:text>
228    <xsl:for-each select="ex:nodeset($top2)//center/preceding-sibling::t2-west">
229      <xsl:value-of select="name(.)"/>
230      <xsl:text>,</xsl:text>
231    </xsl:for-each>
232    <xsl:text>
233</xsl:text>
234
235    <xsl:text>N07: center/following::t2-east nodes in $top2 are </xsl:text>
236    <xsl:for-each select="ex:nodeset($top2)//center/following::t2-east">
237      <xsl:value-of select="name(.)"/>
238      <xsl:text>,</xsl:text>
239    </xsl:for-each>
240    <xsl:text>
241</xsl:text>
242
243    <xsl:text>N08: center/preceding::t2-west nodes in $top2 are </xsl:text>
244    <xsl:for-each select="ex:nodeset($top2)//center/preceding::t2-west">
245      <xsl:value-of select="name(.)"/>
246      <xsl:text>,</xsl:text>
247    </xsl:for-each>
248    <xsl:text>
249</xsl:text>
250
251    <xsl:text>N09: center/attribute::center-attr-1 nodes in $top2 are </xsl:text>
252    <xsl:for-each select="ex:nodeset($top2)//center/attribute::center-attr-1">
253      <xsl:value-of select="name(.)"/>
254      <xsl:text>,</xsl:text>
255    </xsl:for-each>
256    <xsl:text>
257</xsl:text>
258
259    <xsl:text>N10: center/self::center nodes in $top2 are </xsl:text>
260    <xsl:for-each select="ex:nodeset($top2)//center/self::center">
261      <xsl:value-of select="name(.)"/>
262      <xsl:text>,</xsl:text>
263    </xsl:for-each>
264    <xsl:text>
265</xsl:text>
266
267    <xsl:text>N11: center/descendant-or-self::t2-south nodes in $top2 are </xsl:text>
268    <xsl:for-each select="ex:nodeset($top2)//center/descendant-or-self::t2-south">
269      <xsl:value-of select="name(.)"/>
270      <xsl:text>,</xsl:text>
271    </xsl:for-each>
272    <xsl:text>
273</xsl:text>
274
275    <xsl:text>N12: center/ancestor-or-self::t2-north nodes in $top2 are </xsl:text>
276    <xsl:for-each select="ex:nodeset($top2)//center/ancestor-or-self::t2-north">
277      <xsl:value-of select="name(.)"/>
278      <xsl:text>,</xsl:text>
279    </xsl:for-each>
280    <xsl:text>
281</xsl:text>
282  </out>
283</xsl:template>
284
285
286  <!--
287   * Licensed to the Apache Software Foundation (ASF) under one
288   * or more contributor license agreements. See the NOTICE file
289   * distributed with this work for additional information
290   * regarding copyright ownership. The ASF licenses this file
291   * to you under the Apache License, Version 2.0 (the  "License");
292   * you may not use this file except in compliance with the License.
293   * You may obtain a copy of the License at
294   *
295   *     http://www.apache.org/licenses/LICENSE-2.0
296   *
297   * Unless required by applicable law or agreed to in writing, software
298   * distributed under the License is distributed on an "AS IS" BASIS,
299   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
300   * See the License for the specific language governing permissions and
301   * limitations under the License.
302  -->
303
304</xsl:stylesheet>
305