xref: /aosp_15_r20/external/apache-xml/test/tests/conf/conditional/conditional19.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: conditional19 -->
5  <!-- Document: http://www.w3.org/TR/xslt -->
6  <!-- DocVersion: 19991116 -->
7  <!-- Section: 9.2 -->
8  <!-- Creator: David Marston -->
9  <!-- Purpose: Test that xsl:choose can be nested. -->
10
11<xsl:template match="/doc">
12  <out>
13    <xsl:for-each select=".//title">
14      <xsl:choose>
15        <xsl:when test=".='Level A'">*A+</xsl:when>
16        <xsl:when test=".='Level B'">B+</xsl:when>
17        <xsl:when test=".='Level C'">
18          <xsl:choose><!-- When on a C, look ahead -->
19            <xsl:when test="name(following-sibling::*[1])='d'">C+</xsl:when>
20            <xsl:when test="name(../following-sibling::*[1])='c'">C:</xsl:when>
21            <xsl:when test="name(../../following-sibling::*[1])='b'">C-</xsl:when>
22            <xsl:otherwise>!Bad tree!</xsl:otherwise>
23          </xsl:choose>
24        </xsl:when>
25        <xsl:when test=".='Level D'">
26          <xsl:choose><!-- When on a D, look ahead -->
27            <xsl:when test="name(following-sibling::*[1])='e'">D+</xsl:when>
28            <xsl:when test="name(../following-sibling::*[1])='d'">D:</xsl:when>
29            <xsl:otherwise><!-- We're backing up, but how far? -->
30              <xsl:choose>
31                <xsl:when test="name(../../following-sibling::*[1])='c'">D-</xsl:when>
32                <xsl:otherwise>D|</xsl:otherwise>
33              </xsl:choose>
34            </xsl:otherwise>
35          </xsl:choose>
36        </xsl:when>
37        <xsl:when test=".='Level E'">E-</xsl:when>
38        <xsl:otherwise>TREE: </xsl:otherwise>
39      </xsl:choose>
40    </xsl:for-each>
41  </out>
42</xsl:template>
43
44
45  <!--
46   * Licensed to the Apache Software Foundation (ASF) under one
47   * or more contributor license agreements. See the NOTICE file
48   * distributed with this work for additional information
49   * regarding copyright ownership. The ASF licenses this file
50   * to you under the Apache License, Version 2.0 (the  "License");
51   * you may not use this file except in compliance with the License.
52   * You may obtain a copy of the License at
53   *
54   *     http://www.apache.org/licenses/LICENSE-2.0
55   *
56   * Unless required by applicable law or agreed to in writing, software
57   * distributed under the License is distributed on an "AS IS" BASIS,
58   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59   * See the License for the specific language governing permissions and
60   * limitations under the License.
61  -->
62
63</xsl:stylesheet>
64