xref: /aosp_15_r20/external/apache-xml/test/tests/extensions/library/libraryNodeset08.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: libraryNodeset08 -->
7  <!-- Document: http://www.w3.org/TR/xslt -->
8  <!-- DocVersion: 19991116 -->
9  <!-- Section: 11.4 -->
10  <!-- Creator: Joe Kesselman -->
11  <!-- Purpose: Try paths from nodeset of local RTF; ensure we get the right one. -->
12
13<xsl:output method="xml" indent="no" encoding="UTF-8"/>
14
15<xsl:template match="/">
16  <xsl:variable name="var1">
17    <t1-far-north>
18      <t1-north>
19        <t1-near-north>
20          <t1-far-west/>
21          <t1-west/>
22          <t1-near-west/>
23          <center center-attr-1="c1" xmlns:n="http://example.com">Wrong variable, can you dig it?
24            <t1-near-south>
25              <t1-south>
26                <t1-far-south/>
27              </t1-south>
28            </t1-near-south>
29          </center>
30          <t1-near-east/>
31          <t1-east/>
32          <t1-far-east/>
33        </t1-near-north>
34      </t1-north>
35    </t1-far-north>
36  </xsl:variable>
37
38  <xsl:variable name="var2">
39    <t2-far-north>
40      <t2-north>
41        <t2-near-north>
42          <t2-far-west/>
43          <t2-west/>
44          <t2-near-west/>
45          <center center-attr-1="c2" xmlns:n="http://example.com">Dig we must!
46            <t2-near-south>
47              <t2-south>
48                <t2-far-south/>
49              </t2-south>
50            </t2-near-south>
51          </center>
52          <t2-near-east/>
53          <t2-east/>
54          <t2-far-east/>
55        </t2-near-north>
56      </t2-north>
57    </t2-far-north>
58  </xsl:variable>
59
60  <out>
61    <!-- Now, force evaluation of each of the above variables -->
62    <junk>
63      <xsl:text>$var1 summary: </xsl:text>
64      <xsl:value-of select="$var1"/>
65      <xsl:text>
66</xsl:text>
67      <xsl:text>$var2 summary: </xsl:text>
68      <xsl:value-of select="$var2"/>
69    </junk>
70
71    <!-- Now, traverse some axes -->
72    <xsl:apply-templates select="ex:nodeset($var2)//t2-north"/>
73  </out>
74</xsl:template>
75
76<xsl:template match="t2-north">
77  <!-- DS means the location path is optimizable as a single descendant iterator. -->
78DS   1. AC: <xsl:value-of select="name(/descendant-or-self::t2-north)"/>
79DS   2. AD: <xsl:value-of select="name(/descendant::t2-near-north)"/>
80DS   3. BC: <xsl:value-of select="name(self::node()/descendant-or-self::t2-north)"/>
81DS   4. BD: <xsl:value-of select="name(self::node()/descendant::t2-near-north)"/>
82NDS  5. CC: <xsl:value-of select="name(descendant-or-self::t2-north/descendant-or-self::t2-north)"/>
83NDS  6. CD: <xsl:value-of select="name(descendant-or-self::t2-north/descendant::t2-near-north)"/>
84NDS  7. CE: <xsl:value-of select="name(descendant-or-self::t2-north/child::t2-near-north)"/>
85NDS  8. DC: <xsl:value-of select="name(descendant::t2-near-north/descendant-or-self::t2-near-north)"/>
86NDS  9. DD: <xsl:value-of select="name(descendant::t2-near-north/descendant::t2-far-west)"/>
87
88NDS 10. ACC: <xsl:value-of select="name(/descendant-or-self::t2-north/descendant-or-self::t2-north)"/>
89NDS 11. ACE: <xsl:value-of select="name(/descendant-or-self::t2-north/child::t2-near-north)"/>
90NDS 12. ADC: <xsl:value-of select="name(/descendant::t2-near-north/descendant-or-self::t2-near-north)"/>
91NDS 13. BCC: <xsl:value-of select="name(self::node()/descendant-or-self::t2-north/descendant-or-self::t2-north)"/>
92NDS 14. BCE: <xsl:value-of select="name(self::node()/descendant-or-self::t2-north/child::t2-near-north)"/>
93NDS 15. BDC: <xsl:value-of select="name(self::node()/descendant::t2-near-north/descendant-or-self::t2-far-west)"/>
94NDS 16. BDE: <xsl:value-of select="name(self::node()/descendant::t2-near-north/child::t2-far-west)"/>
95NDS 17. CCC: <xsl:value-of select="name(descendant-or-self::t2-north/descendant-or-self::t2-north/descendant-or-self::t2-north)"/>
96NDS 18. CCE: <xsl:value-of select="name(descendant-or-self::t2-north/descendant-or-self::t2-north/child::t2-near-north)"/>
97NDS 19. CDC: <xsl:value-of select="name(descendant-or-self::t2-north/descendant::t2-near-north/descendant-or-self::t2-near-north)"/>
98NDS 20. CDE: <xsl:value-of select="name(descendant-or-self::t2-north/descendant::t2-near-north/child::t2-far-west)"/>
99NDS 21. CEC: <xsl:value-of select="name(descendant-or-self::t2-north/child::t2-near-north/descendant-or-self::t2-near-north)"/>
100NDS 22. CEE: <xsl:value-of select="name(descendant-or-self::t2-north/child::t2-near-north/child::t2-far-west)"/>
101NDS 23. DCC: <xsl:value-of select="name(descendant::t2-near-north/descendant-or-self::t2-near-north/descendant-or-self::t2-near-north)"/>
102NDS 24. DCE: <xsl:value-of select="name(descendant::t2-near-north/descendant-or-self::t2-near-north/child::t2-far-west)"/>
103NDS 25. DDC: <xsl:value-of select="name(descendant::t2-near-north/descendant::t2-far-west/descendant-or-self::t2-far-west)"/>
104
105DS  26. CC: <xsl:value-of select="name(descendant-or-self::node()/descendant-or-self::t2-north)"/>
106DS  27. CD: <xsl:value-of select="name(descendant-or-self::node()/descendant::t2-near-north)"/>
107DS  28. CE: <xsl:value-of select="name(descendant-or-self::node()/child::t2-near-north)"/>
108DS  29. DC: <xsl:value-of select="name(descendant::node()/descendant-or-self::t2-near-north)"/>
109DS  30. DD: <xsl:value-of select="name(descendant::node()/descendant::t2-far-west)"/>
110
111DS  31. ACC: <xsl:value-of select="name(/descendant-or-self::node()/descendant-or-self::t2-north)"/>
112DS  32. ACE: <xsl:value-of select="name(/descendant-or-self::node()/child::t2-near-north)"/>
113DS  33. ADC: <xsl:value-of select="name(/descendant::node()/descendant-or-self::t2-near-north)"/>
114DS  34. BCC: <xsl:value-of select="name(self::node()/descendant-or-self::node()/descendant-or-self::t2-north)"/>
115DS  35. BCE: <xsl:value-of select="name(self::node()/descendant-or-self::node()/child::t2-near-north)"/>
116DS  36. BDC: <xsl:value-of select="name(self::node()/descendant::node()/descendant-or-self::t2-far-west)"/>
117DS  37. BDE: <xsl:value-of select="name(self::node()/descendant::node()/child::t2-far-west)"/>
118DS  38. CCC: <xsl:value-of select="name(descendant-or-self::node()/descendant-or-self::node()/descendant-or-self::t2-north)"/>
119DS  39. CCE: <xsl:value-of select="name(descendant-or-self::node()/descendant-or-self::node()/child::t2-near-north)"/>
120DS  40. CDC: <xsl:value-of select="name(descendant-or-self::node()/descendant::node()/descendant-or-self::t2-near-north)"/>
121DS  41. CDE: <xsl:value-of select="name(descendant-or-self::node()/descendant::node()/child::t2-far-west)"/>
122DS  42. CEC: <xsl:value-of select="name(descendant-or-self::node()/child::node()/descendant-or-self::t2-near-north)"/>
123DS  43. CEE: <xsl:value-of select="name(descendant-or-self::node()/child::node()/child::t2-far-west)"/>
124DS  44. DCC: <xsl:value-of select="name(descendant::node()/descendant-or-self::node()/descendant-or-self::t2-near-north)"/>
125DS  45. DCE: <xsl:value-of select="name(descendant::node()/descendant-or-self::node()/child::t2-far-west)"/>
126DS  46. DDC: <xsl:value-of select="name(descendant::node()/descendant::node()/descendant-or-self::t2-far-west)"/>
127</xsl:template>
128
129
130  <!--
131   * Licensed to the Apache Software Foundation (ASF) under one
132   * or more contributor license agreements. See the NOTICE file
133   * distributed with this work for additional information
134   * regarding copyright ownership. The ASF licenses this file
135   * to you under the Apache License, Version 2.0 (the  "License");
136   * you may not use this file except in compliance with the License.
137   * You may obtain a copy of the License at
138   *
139   *     http://www.apache.org/licenses/LICENSE-2.0
140   *
141   * Unless required by applicable law or agreed to in writing, software
142   * distributed under the License is distributed on an "AS IS" BASIS,
143   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144   * See the License for the specific language governing permissions and
145   * limitations under the License.
146  -->
147
148</xsl:stylesheet>
149