xref: /aosp_15_r20/external/apache-xml/test/tests/extensions/java/javaSample3.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:java="http://xml.apache.org/xslt/java"
4                version="1.0">
5
6<!-- Copied from: java/samples/extensions/3-java-namespace.xsl -->
7<xsl:output method="xml" indent="yes"/>
8
9  <xsl:template match="/">
10    <out>
11      <xsl:apply-templates select="/doc/date"/>
12    </out>
13  </xsl:template>
14
15  <xsl:template match="date">
16    <xsl:variable name="year" select="string(@year)"/>
17    <xsl:variable name="month" select="string(@month)"/>
18    <xsl:variable name="day" select="string(@day)"/>
19    <xsl:variable name="format" select="string(@format)"/>
20    <xsl:variable name="formatter"
21         select="java:java.text.SimpleDateFormat.new($format)"/>
22    <xsl:variable name="date"
23         select="java:javaSample3.getDate($year,$month,$day)"/>
24    <p>Format:   <xsl:value-of select="$format"/></p>
25    <p>Date-xml: y:<xsl:value-of select="$year"/> m:<xsl:value-of select="$month"/> d:<xsl:value-of select="$day"/></p>
26    <p>Date-ext: <xsl:value-of select="java:format($formatter, $date)"/></p>
27  </xsl:template>
28
29
30  <!--
31   * Licensed to the Apache Software Foundation (ASF) under one
32   * or more contributor license agreements. See the NOTICE file
33   * distributed with this work for additional information
34   * regarding copyright ownership. The ASF licenses this file
35   * to you under the Apache License, Version 2.0 (the  "License");
36   * you may not use this file except in compliance with the License.
37   * You may obtain a copy of the License at
38   *
39   *     http://www.apache.org/licenses/LICENSE-2.0
40   *
41   * Unless required by applicable law or agreed to in writing, software
42   * distributed under the License is distributed on an "AS IS" BASIS,
43   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44   * See the License for the specific language governing permissions and
45   * limitations under the License.
46  -->
47
48</xsl:stylesheet>
49