The following xslt stylesheet transforms the gedcom file into a Graphiz/DOT input which can be used to generate the family tree.
<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:output method='text' omit-xml-declaration="yes" />
<xsl:template match="GEDCOM">
digraph "G" {
<xsl:apply-templates select="FamilyRec"/>
<xsl:apply-templates select="IndividualRec"/>
}
</xsl:template>
<xsl:template match="IndividualRec">
<xsl:value-of select="@Id"/>[ shape=box, label="<xsl:value-of select="IndivName/GivenName"/><xsl:text> </xsl:text><xsl:value-of select="IndivName/SurName"/> <xsl:if test="DeathStatus='dead;'">(d)</xsl:if>"
<xsl:choose>
<xsl:when test="Gender='M'">
,color=blue
</xsl:when>
<xsl:when test="Gender='F'">
,color=pink
</xsl:when>
<xsl:otherwise>
,color=black
</xsl:otherwise>
</xsl:choose>
];
</xsl:template>
<xsl:template match="FamilyRec">
<xsl:variable name="famId"><xsl:value-of select="@Id"/></xsl:variable>
<xsl:value-of select="$famId"/>[shape=point];
<xsl:if test="HusbFath">
<xsl:value-of select="HusbFath/Link/@Ref"/>-><xsl:value-of select="$famId"/>;
</xsl:if>
<xsl:if test="WifeMoth">
<xsl:value-of select="WifeMoth/Link/@Ref"/>-><xsl:value-of select="$famId"/>;
</xsl:if>
<xsl:for-each select="Child">
<xsl:value-of select="$famId"/>-><xsl:value-of select="Link/@Ref"/>;
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Pierre
No comments:
Post a Comment