xref: /aosp_15_r20/external/apache-xml/test/tests/extensions/library/libraryEvaluate01.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
3    xmlns:xalan="http://xml.apache.org/xalan"
4    exclude-result-prefixes="xalan">
5
6  <!-- FileName: libraryEvaluate01.xsl -->
7  <!-- Document: http://www.w3.org/TR/xslt -->
8  <!-- DocVersion: 19991116 -->
9  <!-- Creator: Shane Curcuru -->
10  <!-- Purpose: Basic test of evaluate() extension function -->
11
12<xsl:param name="param1">sum(item)</xsl:param>
13
14<xsl:template match="doc">
15  <out>
16    <sum-expr>
17      <xsl:value-of select="$param1"/>
18    </sum-expr>
19    <xsl:apply-templates select="list"/>
20  </out>
21</xsl:template>
22
23<xsl:template match="list">
24    <xsl:element name="listout">
25      <xsl:attribute name="sum-function">
26        <xsl:value-of select="sum(item)"/>
27      </xsl:attribute>
28      <xsl:attribute name="sum-evaluate">
29        <!-- Use string() to force the variable to be a string to be evaluated -->
30        <xsl:value-of select="xalan:evaluate( string($param1) )"/>
31      </xsl:attribute>
32    <xsl:apply-templates select="list"/>
33    </xsl:element>
34</xsl:template>
35
36  <!--
37   * Licensed to the Apache Software Foundation (ASF) under one
38   * or more contributor license agreements. See the NOTICE file
39   * distributed with this work for additional information
40   * regarding copyright ownership. The ASF licenses this file
41   * to you under the Apache License, Version 2.0 (the  "License");
42   * you may not use this file except in compliance with the License.
43   * You may obtain a copy of the License at
44   *
45   *     http://www.apache.org/licenses/LICENSE-2.0
46   *
47   * Unless required by applicable law or agreed to in writing, software
48   * distributed under the License is distributed on an "AS IS" BASIS,
49   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50   * See the License for the specific language governing permissions and
51   * limitations under the License.
52  -->
53
54</xsl:stylesheet>
55