DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Geni2gedcom

05.31.2007
| 3423 views |
  • submit to reddit
        Tansform gedcom-XML output of geni.com to dot file for graphviz

<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:output method='text'/>

<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"/>[ label="<xsl:value-of select="IndivNam
e/GivenName"/><xsl:text> </xsl:text><xsl:value-of select="IndivName/SurName"/> &
quot;];
</xsl:template>

<xsl:template match="FamilyRec">
        <xsl:variable name="famId"><xsl:value-of select="@Id"/></xsl:variable>
        <xsl:if test="HusbFath">
                <xsl:value-of select="HusbFath/Link/@Ref"/>-><xsl:value-of se
lect="$famId"/>;
        </xsl:if>

        <xsl:if test="WifeMoth">
                <xsl:value-of select="WifeMoth/Link/@Ref"/>-><xsl:value-of se
lect="$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>