xref: /aosp_15_r20/external/apache-xml/test/tests/capi/smoke/capi01.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:dick="http://www.dicks.com"
4				xmlns:weston="http://www.weston.com"
5				exclude-result-prefixes="dick weston">
6
7<xsl:import href="smokesubdir/famimp.xsl"/>
8<xsl:include href="smokesubdir/faminc.xsl"/>
9
10<xsl:output indent="yes"/>
11
12<xsl:strip-space elements="Family_Geneologies Kids Males"/>
13<xsl:variable name="root" select="'Families'"/>
14
15<!-- Root xsl:template - start processing here -->
16<xsl:key name="KidInfo" match="Kid" use="@ID"/>
17
18<xsl:template match="Family_Geneologies">
19  <out>
20     <xsl:apply-templates select="Family"/>
21  </out>
22</xsl:template>
23
24
25<xsl:template match="Family">
26<xsl:text>&#10;</xsl:text>
27
28	<xsl:call-template name="tree">
29	   <xsl:with-param name="Surname" select="@Surname"/>
30	</xsl:call-template><xsl:text>&#10;</xsl:text>
31
32	<xsl:value-of select="@Surname" />
33
34    <xsl:apply-templates select="Parents">
35	   <xsl:with-param name="Surname" select="@Surname"/>
36	</xsl:apply-templates>
37
38	<xsl:apply-templates select="Children/Child">
39	   <xsl:sort select="Basic_Information/Name/@First"/>
40	</xsl:apply-templates>
41
42</xsl:template>
43
44<xsl:template match="Child">
45	<xsl:text>&#10;&#13;</xsl:text>
46	<xsl:value-of select=".//Name"/>'s phone number is <xsl:value-of select=".//Phone/Home"/><xsl:text>.</xsl:text>
47	<xsl:if test='Personal_Information/Sex[.="Male"]' ><xsl:text/>
48He is <xsl:value-of select="Personal_Information/Age"/><xsl:text>. </xsl:text>
49	</xsl:if>
50	<xsl:if test='Personal_Information/Sex[.="Female"]' >
51She is <xsl:value-of select="Personal_Information/Age"/><xsl:text>. </xsl:text>
52	</xsl:if>
53	<xsl:apply-templates select="Personal_Information/Married"/>
54</xsl:template>
55
56<xsl:template match ="Personal_Information/Married">
57  <xsl:variable name="spouse" select="following-sibling::*/Wife/Name | following-sibling::*/child::Husband/child::Name"/>
58	<xsl:if test='.="Yes"' >
59		<xsl:value-of select="ancestor::Child/Basic_Information/Name/@First"/> is married to <xsl:value-of select="$spouse"/>
60		<xsl:text>.</xsl:text>
61		<xsl:choose>
62			<xsl:when test="./@Kids > 0">
63Their children are <xsl:text/>
64				<xsl:for-each select="following-sibling::*/child::Kids/child::Kid">
65				   <!--xsl:value-of select="."/-->
66				   <xsl:choose>
67						<xsl:when test="(position()=last())">
68							<xsl:value-of select="Name"/>:<xsl:value-of select="Age"/></xsl:when>
69						<xsl:otherwise>
70				   			<xsl:value-of select="Name"/>:<xsl:value-of select="Age"/><xsl:text>, </xsl:text></xsl:otherwise>
71				   </xsl:choose>
72				   <xsl:if test="(position()=last()-1)">and </xsl:if>
73				</xsl:for-each>
74			</xsl:when>
75			<xsl:when test="./@Kids = 0">
76They have no kids
77			</xsl:when>
78		</xsl:choose>
79	</xsl:if>
80	<xsl:if test='.="No"'>
81		<xsl:value-of select="ancestor::Child/child::Basic_Information/child::Name/@First"/> is not married.
82		<!-- The following is another way to print out the same message
83		<xsl:value-of select="../..//Basic_Information/Name/@First"/> is not married   -->
84	</xsl:if>
85</xsl:template>
86
87<xsl:template match ="Parents">
88   <xsl:param name="Surname" select="'Default'"/>
89The parents are: <xsl:value-of select="Father/@First"/> and <xsl:value-of select="Mother"/>
90    <xsl:choose>
91       <xsl:when test="contains($Surname,'Dicks')">
92          <xsl:apply-templates select="GrandKids" mode="document"/>
93	   </xsl:when>
94	   <xsl:otherwise>
95          <xsl:apply-templates select="GrandKids" mode="orginal"/>
96	   </xsl:otherwise>
97	</xsl:choose>
98</xsl:template>
99
100
101
102  <!--
103   * Licensed to the Apache Software Foundation (ASF) under one
104   * or more contributor license agreements. See the NOTICE file
105   * distributed with this work for additional information
106   * regarding copyright ownership. The ASF licenses this file
107   * to you under the Apache License, Version 2.0 (the  "License");
108   * you may not use this file except in compliance with the License.
109   * You may obtain a copy of the License at
110   *
111   *     http://www.apache.org/licenses/LICENSE-2.0
112   *
113   * Unless required by applicable law or agreed to in writing, software
114   * distributed under the License is distributed on an "AS IS" BASIS,
115   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116   * See the License for the specific language governing permissions and
117   * limitations under the License.
118  -->
119
120</xsl:stylesheet>
121