xref: /aosp_15_r20/external/apache-xml/test/tests/bugzilla/Bugzilla4218.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet
3  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4  version="1.0">
5<!-- Reproduce Bugzilla#4218, apply this to identity.xml or any file -->
6<!--
7The following stylesheet puts out <out>abcabc</out>, which is absolutely
8incorrect.  If you uncomment the commented value-of and variable, it results
9"Variable accessed before it is bound!" error message.  The bug seems to be
10related to the inner call-template... it looks like something in the stack
11frame is not being restored???
12-->
13<xsl:template match="/">
14    <out>
15      <xsl:variable name="v1" select="'abc-should-appear-once'"/>
16      <xsl:variable name="v2" select="'def-should-appear-once'"/>
17
18      <xsl:variable name="v3" select="'ghi-should-appear-once'"/>
19
20      <xsl:call-template name="test-template">
21        <xsl:with-param name="p1">
22          <xsl:call-template name="xyz-template">
23            <xsl:with-param name="p1" select="$v1"/>
24          </xsl:call-template>
25          <xsl:value-of select="$v2"/>
26          <!-- Comment this in, to get error message:
27               Variable accessed before it is bound!
28               See Bugzilla4218a.xsl -->
29          <!-- xsl:value-of select="$v3"/ -->
30        </xsl:with-param>
31      </xsl:call-template>
32    </out>
33  </xsl:template>
34
35  <xsl:template name="test-template">
36    <xsl:param name="p1" select="'error'"/>
37    <test-template><xsl:value-of select="$p1"/></test-template>
38  </xsl:template>
39
40  <xsl:template name="xyz-template">
41    <xsl:param name="p1" select="'error'"/>
42    <xyz-template><xsl:value-of select="$p1"/></xyz-template>
43  </xsl:template>
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