xref: /aosp_15_r20/external/apache-xml/test/tests/capi/smoke/smokesubdir/faminc.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<xsl:template name="tree">
5   <xsl:param name="Surname" select="Default"/>
6
7   <xsl:element name="{$root}">
8   <xsl:element name="{substring-after($Surname,'The ')}">
9
10       <!-- Start with the Parents.-->
11	   <xsl:element name="Parents">
12	   <xsl:for-each select="Parents/Father | Parents/Mother">
13		  <xsl:element name="{name(.)}">
14		     <xsl:value-of select="."/>
15		  </xsl:element>
16	   </xsl:for-each>
17	   </xsl:element>
18
19	   <!-- Then the Children. -->
20       <xsl:element name="Children">
21	   <xsl:attribute name="number">
22	      <xsl:value-of select="count(Children/Child)"/>
23	   </xsl:attribute>
24	   <xsl:for-each select="Children/Child">
25		     <xsl:element name="{Personal_Information/Sex}">
26
27			  <xsl:attribute name="name">
28			     <xsl:value-of select="Basic_Information/Name/@First"/>
29			  </xsl:attribute>
30			  <xsl:choose>
31			  <xsl:when test="Personal_Information/Sex='Male'">
32				<xsl:attribute name="wife">
33					<xsl:value-of select="Personal_Information/Family_Information/Wife/Name/@First"/>
34				</xsl:attribute>
35			  </xsl:when>
36			  <xsl:when test="Personal_Information/Sex='Female'">
37				<xsl:attribute name="husband">
38					<xsl:value-of select="Personal_Information/Family_Information/Husband/Name/@First"/>
39				</xsl:attribute>
40			  </xsl:when>
41			  </xsl:choose>
42
43			  <xsl:attribute name="kids">
44				  <xsl:value-of select="count(Personal_Information/Family_Information/Kids/Kid)"/>
45			  </xsl:attribute>
46
47			  <xsl:if test="count(Personal_Information/Family_Information/Kids/Kid)">
48			     <xsl:element name="Kids">
49			        <xsl:for-each select="Personal_Information/Family_Information/Kids/Kid">
50			           <xsl:element name="Grandkid"><xsl:value-of select="Name/@First"/></xsl:element>
51			        </xsl:for-each>
52			     </xsl:element>
53			  </xsl:if>
54
55			  <xsl:value-of select="Basic_Information/Name/@First"/>
56			 </xsl:element>
57	   </xsl:for-each>
58	   </xsl:element>
59
60   </xsl:element>
61   </xsl:element>
62</xsl:template>
63
64  <!--
65   * Licensed to the Apache Software Foundation (ASF) under one
66   * or more contributor license agreements. See the NOTICE file
67   * distributed with this work for additional information
68   * regarding copyright ownership. The ASF licenses this file
69   * to you under the Apache License, Version 2.0 (the  "License");
70   * you may not use this file except in compliance with the License.
71   * You may obtain a copy of the License at
72   *
73   *     http://www.apache.org/licenses/LICENSE-2.0
74   *
75   * Unless required by applicable law or agreed to in writing, software
76   * distributed under the License is distributed on an "AS IS" BASIS,
77   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
78   * See the License for the specific language governing permissions and
79   * limitations under the License.
80  -->
81
82</xsl:stylesheet>
83