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: Paul_Dick@lotus.com --> 9 <!-- Author: Shane_Curcuru@lotus.com 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/> 51 He is <xsl:value-of select="Personal_Information/Age"/><xsl:text>. </xsl:text> 52 </xsl:if> 53 <xsl:if test='Personal_Information/Sex[.="Female"]' > 54 She 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"> 66 Their 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"> 79 They 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'"/> 92 The 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 </xsl:stylesheet>