xref: /aosp_15_r20/external/apache-xml/test/tests/conf/modes/modes10.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: MODES10 -->
5  <!-- Document: http://www.w3.org/TR/xslt -->
6  <!-- DocVersion: 19991116 -->
7  <!-- Section: 5.7 Modes -->
8  <!-- Creator: David Marston -->
9  <!-- Purpose: Show that we only go into a mode via apply-templates.
10     You can't put a mode on call-template, and the fact that you call a named
11     template that has a mode specifier doesn't mean you are in that mode. -->
12
13<xsl:template match="/">
14  <out>
15    <xsl:apply-templates select="doc" mode="a"/>
16  </out>
17</xsl:template>
18
19<xsl:template match="doc" mode="a" priority="3">
20  <xsl:text>Found doc...</xsl:text>
21  <xsl:call-template name="scan"/>
22</xsl:template>
23
24<!-- The following template is both applied in mode a and called -->
25<xsl:template name="scan" match="*" mode="a" priority="2">
26  <xsl:text>Scanned </xsl:text><xsl:value-of select="name(.)"/><xsl:text>
27</xsl:text>
28  <xsl:apply-templates/>
29</xsl:template>
30
31<xsl:template match="x" priority="4">
32  <xsl:text>Found x, no mode: </xsl:text><xsl:value-of select="."/><xsl:text>
33</xsl:text>
34  <xsl:apply-templates mode="a"/>
35</xsl:template>
36
37<xsl:template match="x" mode="a" priority="4">
38  <xsl:text>Found x, mode a: </xsl:text><xsl:value-of select="@test"/><xsl:text>
39</xsl:text>
40</xsl:template>
41
42<xsl:template match="text()">
43  <xsl:text>modeless text: </xsl:text><xsl:value-of select="."/><xsl:text>
44</xsl:text>
45</xsl:template>
46
47<xsl:template match="text()" mode="a">
48  <xsl:text>mode a text: </xsl:text><xsl:value-of select="."/>
49</xsl:template>
50
51
52  <!--
53   * Licensed to the Apache Software Foundation (ASF) under one
54   * or more contributor license agreements. See the NOTICE file
55   * distributed with this work for additional information
56   * regarding copyright ownership. The ASF licenses this file
57   * to you under the Apache License, Version 2.0 (the  "License");
58   * you may not use this file except in compliance with the License.
59   * You may obtain a copy of the License at
60   *
61   *     http://www.apache.org/licenses/LICENSE-2.0
62   *
63   * Unless required by applicable law or agreed to in writing, software
64   * distributed under the License is distributed on an "AS IS" BASIS,
65   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66   * See the License for the specific language governing permissions and
67   * limitations under the License.
68  -->
69
70</xsl:stylesheet>
71