xref: /aosp_15_r20/external/apache-xml/test/tests/conf/idkey/idkey22.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4  <!-- FileName: idkey22 -->
5  <!-- Document: http://www.w3.org/TR/xpath -->
6  <!-- DocVersion: 19991116 -->
7  <!-- Section: 4.1 -->
8  <!-- Creator: David Marston (original idea sent in by user) -->
9  <!-- Purpose: Test for id() in complex structure. -->
10
11<xsl:template match="/">
12  <out>
13    <xsl:apply-templates/>
14  </out>
15</xsl:template>
16
17<xsl:template match="doc">
18  Test for id selection and pattern matching...
19  Next line should read: -*id17*-    <!-- No id() either end -->
20  <xsl:apply-templates select="c/b"/>
21  Next line should read: (*id14*)    <!-- id() below but not here -->
22  <xsl:apply-templates select="b/c"/>
23  Next line should read: -*id4*-     <!-- id() here on apply but not below -->
24  <xsl:apply-templates select="id('id4')"/>
25  Next line should read: +*id9*+     <!-- id() same on both ends -->
26  <xsl:apply-templates select="id('id9')"/>
27  Next line should read: (*id13*)    <!-- simple id() here, path off top-level id() below -->
28  <xsl:apply-templates select="id('id13')"/>
29  Next line should read: -*id6*-     <!-- path off top-level id() here but not below -->
30  <xsl:apply-templates select="id('id0')/a/b"/>
31  Next line should read: @*id19*@    <!-- same path off top-level id() here and below -->
32  <xsl:apply-templates select="id('id0')/c/c/a"/>
33  Next line should read: %*id12*%    <!-- different paths off id() here and below -->
34  <xsl:apply-templates select="id('id8')/b/b"/>
35  Next line should read: !*id11*!    <!-- different paths off id(), middle here and top-level below -->
36  <xsl:apply-templates select="id('id10')/a"/>
37  Next line should read: [*id3*] \*id5*\ =*id16*=  <!-- union of id()-based paths -->
38  <xsl:apply-templates select="id('id2')/a | id('id5') | id('id15')/a"/>
39</xsl:template>
40
41<!-- Now the templates for the specific cases -->
42
43<xsl:template match="c">
44  Error if this (c) template fires!
45</xsl:template>
46
47<xsl:template match="b">
48  -<xsl:apply-templates/>-
49</xsl:template>
50
51<xsl:template match="id('id5')">
52  \<xsl:apply-templates/>\
53</xsl:template>
54
55<xsl:template match="id('id9')">
56  +<xsl:apply-templates/>+
57</xsl:template>
58
59<xsl:template match="id('id16')">
60  =<xsl:apply-templates/>=
61</xsl:template>
62
63<xsl:template match="id('id0')/a/a/a">
64  [<xsl:apply-templates/>]
65</xsl:template>
66
67<xsl:template match="id('id0')/b/b/a">
68  !<xsl:apply-templates/>!
69</xsl:template>
70
71<xsl:template match="id('id0')/c/c/a">
72  @<xsl:apply-templates/>@
73</xsl:template>
74
75<xsl:template match="id('id8')//b" priority="1">
76  %<xsl:apply-templates/>%
77</xsl:template>
78
79<xsl:template match="id('id8')//c" priority="2">
80  (<xsl:apply-templates/>)
81</xsl:template>
82
83
84  <!--
85   * Licensed to the Apache Software Foundation (ASF) under one
86   * or more contributor license agreements. See the NOTICE file
87   * distributed with this work for additional information
88   * regarding copyright ownership. The ASF licenses this file
89   * to you under the Apache License, Version 2.0 (the  "License");
90   * you may not use this file except in compliance with the License.
91   * You may obtain a copy of the License at
92   *
93   *     http://www.apache.org/licenses/LICENSE-2.0
94   *
95   * Unless required by applicable law or agreed to in writing, software
96   * distributed under the License is distributed on an "AS IS" BASIS,
97   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
98   * See the License for the specific language governing permissions and
99   * limitations under the License.
100  -->
101
102</xsl:stylesheet>
103