xref: /aosp_15_r20/external/apache-xml/test/tests/conf/select/select68.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: select68 -->
5  <!-- Document: http://www.w3.org/TR/xpath -->
6  <!-- DocVersion: 19991116 -->
7  <!-- Section: 12.1 -->
8  <!-- Creator: David Marston -->
9  <!-- Purpose: Test that document('') refers to this stylesheet, and exploit
10     that fact to have data file select which template to use. -->
11
12<xsl:template match="/document-element">
13  <xsl:variable name="whichtmplt" select="chooser"/>
14  <out>
15    <xsl:apply-templates select="document('')/*/xsl:template[@name=$whichtmplt]"/>
16  </out>
17</xsl:template>
18
19<xsl:template name="this" match="xsl:template">This template.
20  <xsl:apply-templates select="document('select68.xml')//inside" mode="thismode"/>
21</xsl:template>
22
23<xsl:template name="that" match="xsl:template">That template.
24  <xsl:apply-templates select="document('select68.xml')//inside" mode="thatmode"/>
25</xsl:template>
26
27<xsl:template match="inside" mode="thismode">We are inside.
28  <xsl:value-of select="@xx"/>
29</xsl:template>
30
31<xsl:template match="inside" mode="thatmode">We got inside.
32  <xsl:value-of select="@flag"/>
33</xsl:template>
34
35<xsl:template match="inside">We got inside, but modeless.
36  <xsl:value-of select="."/>
37</xsl:template>
38
39<xsl:template name="the_other" match="*">We are generic.
40  <xsl:value-of select="name(.)"/>
41</xsl:template>
42
43
44  <!--
45   * Licensed to the Apache Software Foundation (ASF) under one
46   * or more contributor license agreements. See the NOTICE file
47   * distributed with this work for additional information
48   * regarding copyright ownership. The ASF licenses this file
49   * to you under the Apache License, Version 2.0 (the  "License");
50   * you may not use this file except in compliance with the License.
51   * You may obtain a copy of the License at
52   *
53   *     http://www.apache.org/licenses/LICENSE-2.0
54   *
55   * Unless required by applicable law or agreed to in writing, software
56   * distributed under the License is distributed on an "AS IS" BASIS,
57   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58   * See the License for the specific language governing permissions and
59   * limitations under the License.
60  -->
61
62</xsl:stylesheet>
63