xref: /aosp_15_r20/external/apache-xml/test/tests/conf/variable/variable62.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: variable62 -->
5  <!-- Document: http://www.w3.org/TR/xslt -->
6  <!-- DocVersion: 19991116 -->
7  <!-- Section: 11.6 -->
8  <!-- Creator: David Marston -->
9  <!-- Purpose: Test for passing numeric param via apply-templates, with sorting -->
10
11<xsl:output method="xml" encoding="UTF-8"/>
12
13<xsl:template match="doc">
14  <out>
15    <xsl:apply-templates select="a-set">
16      <xsl:sort select="@s" data-type="number" order="ascending"/>
17      <xsl:with-param name="total" select="sum(a-set/a)"/>
18    </xsl:apply-templates>
19  </out>
20</xsl:template>
21
22<xsl:template match="a-set">
23  <xsl:param name="total">Default text in param 1</xsl:param>
24  <xsl:text>&#10;</xsl:text>
25  <list from="{@g}">
26    <xsl:attribute name="proportion">
27      <xsl:value-of select="concat(sum(./a/text()),'/',$total)"/>
28    </xsl:attribute>
29    <xsl:for-each select="./a/text()">
30      <xsl:value-of select="."/>
31      <xsl:text>,</xsl:text>
32    </xsl:for-each>
33  </list>
34</xsl:template>
35
36
37  <!--
38   * Licensed to the Apache Software Foundation (ASF) under one
39   * or more contributor license agreements. See the NOTICE file
40   * distributed with this work for additional information
41   * regarding copyright ownership. The ASF licenses this file
42   * to you under the Apache License, Version 2.0 (the  "License");
43   * you may not use this file except in compliance with the License.
44   * You may obtain a copy of the License at
45   *
46   *     http://www.apache.org/licenses/LICENSE-2.0
47   *
48   * Unless required by applicable law or agreed to in writing, software
49   * distributed under the License is distributed on an "AS IS" BASIS,
50   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51   * See the License for the specific language governing permissions and
52   * limitations under the License.
53  -->
54
55</xsl:stylesheet>
56