xref: /aosp_15_r20/external/apache-xml/test/tests/conf/variable/variable68.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4  <!-- FileName: variable68 -->
5  <!-- Document: http://www.w3.org/TR/xslt -->
6  <!-- DocVersion: 19991116 -->
7  <!-- Section: 11.6 -->
8  <!-- Creator: David Marston -->
9  <!-- Purpose: Demonstrate various tests of nullness on local variables -->
10
11<xsl:output method="xml" indent="no" encoding="UTF-8"/>
12
13<xsl:template match="doc">
14  <xsl:variable name="NotSet"/>
15  <xsl:variable name="String" select="'string'"/>
16  <xsl:variable name="nString" select="''"/>
17  <xsl:variable name="Node" select="a"/>
18  <xsl:variable name="nNode" select="b"/><!-- No element of that name in source. -->
19  <out>
20    <xsl:text>NotSet: </xsl:text>
21    <xsl:choose>
22      <xsl:when test="$NotSet = ''"><xsl:text>equals empty</xsl:text></xsl:when>
23      <xsl:when test="$NotSet != ''"><xsl:text>not empty</xsl:text></xsl:when>
24      <xsl:otherwise><xsl:text>neither</xsl:text></xsl:otherwise>
25    </xsl:choose>
26    <xsl:text>
27String: </xsl:text>
28    <xsl:choose>
29      <xsl:when test="$String = ''"><xsl:text>equals empty</xsl:text></xsl:when>
30      <xsl:when test="$String != ''"><xsl:text>not empty</xsl:text></xsl:when>
31      <xsl:otherwise><xsl:text>neither</xsl:text></xsl:otherwise>
32    </xsl:choose>
33    <xsl:text>
34nString: </xsl:text>
35    <xsl:choose>
36      <xsl:when test="$nString = ''"><xsl:text>equals empty</xsl:text></xsl:when>
37      <xsl:when test="$nString != ''"><xsl:text>not empty</xsl:text></xsl:when>
38      <xsl:otherwise><xsl:text>neither</xsl:text></xsl:otherwise>
39    </xsl:choose>
40    <xsl:text>
41Node: </xsl:text>
42    <xsl:choose>
43      <xsl:when test="$Node = ''"><xsl:text>equals empty</xsl:text></xsl:when>
44      <xsl:when test="$Node != ''"><xsl:text>not empty</xsl:text></xsl:when>
45      <xsl:otherwise><xsl:text>neither</xsl:text></xsl:otherwise>
46    </xsl:choose>
47    <xsl:text>
48nNode: </xsl:text>
49    <xsl:choose>
50      <xsl:when test="$nNode = ''"><xsl:text>equals empty</xsl:text></xsl:when>
51      <xsl:when test="$nNode != ''"><xsl:text>not empty</xsl:text></xsl:when>
52      <xsl:otherwise><xsl:text>neither</xsl:text></xsl:otherwise>
53    </xsl:choose>
54  </out>
55</xsl:template>
56
57
58  <!--
59   * Licensed to the Apache Software Foundation (ASF) under one
60   * or more contributor license agreements. See the NOTICE file
61   * distributed with this work for additional information
62   * regarding copyright ownership. The ASF licenses this file
63   * to you under the Apache License, Version 2.0 (the  "License");
64   * you may not use this file except in compliance with the License.
65   * You may obtain a copy of the License at
66   *
67   *     http://www.apache.org/licenses/LICENSE-2.0
68   *
69   * Unless required by applicable law or agreed to in writing, software
70   * distributed under the License is distributed on an "AS IS" BASIS,
71   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72   * See the License for the specific language governing permissions and
73   * limitations under the License.
74  -->
75
76</xsl:stylesheet>
77