I have XML data where information in nodes relate to other nodes. I am trying to figure out how to generate output based on these relationships.
XML sample
<gedcom>
<indi id="@I001">
<famc>@F002@</famc>
</indi>
...
<fam id="@F002">
<husb>@I005@</husb>
<wife>@I007@</wife>
</fam>
</gedcom>
XSLT sample
<xsl:template match="/">
<xsl:apply-templates select="/gedcom/indi[@id='@I001@']"/>
</xsl:template>
<xsl:template match="indi">
<xsl:value-of select="name/text()"/>
<!-- select the ID of the related FAM node -->
<xsl:variable name="parentsFamily" select="famc/text()"/>
<!-- apply the FAM template to the FAM node reference in the above FAMC node -->
<xsl:apply-templates select="/gedcom/fam[@ID=$parentsFamily]"/>
</xsl:template>
<xsl:template match="fam">
Test
</xsl:template>
The above does not work, but hopefully gives an idea of what I am trying to do. Ultimately I would like to recurse through INDI nodes to related FAM nodes back to related INDI nodes.
Is this even possible with basic XSLT and XPATH functionality?