xref: /aosp_15_r20/external/apache-xml/test/tests/conf/variable/variable51.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version='1.0' encoding='utf-8' ?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
4<xsl:output method="xml" indent="no"/>
5
6  <!-- FileName: variable51 -->
7  <!-- Document: http://www.w3.org/TR/xslt -->
8  <!-- DocVersion: 19991116 -->
9  <!-- Section: 11.2 -->
10  <!-- Creator: John Howard/Tom Amiro -->
11  <!-- Purpose: Set a variable within an if within a for-each. -->
12
13<xsl:template match="/">
14  <xsl:call-template name="Func">
15    <xsl:with-param name="Node" select="."/>
16    <xsl:with-param name="Set" select="/"/>
17  </xsl:call-template>
18</xsl:template>
19
20<xsl:template name="Func">
21  <xsl:param name="Node"/>
22  <xsl:param name="Set"/>
23  <xsl:for-each select="$Set">
24  <!-- declaring b here causes no problems -->
25    <xsl:if test=". = $Node">
26       <xsl:variable name="b" select="1"/><!-- declaring b here was a problem -->
27       <xsl:if test="$b = $b">
28         <out>Passed!</out><xsl:text>&#xA;</xsl:text>
29       </xsl:if>
30     </xsl:if>
31  </xsl:for-each>
32</xsl:template>
33
34
35  <!--
36   * Licensed to the Apache Software Foundation (ASF) under one
37   * or more contributor license agreements. See the NOTICE file
38   * distributed with this work for additional information
39   * regarding copyright ownership. The ASF licenses this file
40   * to you under the Apache License, Version 2.0 (the  "License");
41   * you may not use this file except in compliance with the License.
42   * You may obtain a copy of the License at
43   *
44   *     http://www.apache.org/licenses/LICENSE-2.0
45   *
46   * Unless required by applicable law or agreed to in writing, software
47   * distributed under the License is distributed on an "AS IS" BASIS,
48   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49   * See the License for the specific language governing permissions and
50   * limitations under the License.
51  -->
52
53</xsl:stylesheet>
54