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