jgr
09-10-2005, 10:50 AM
How can I begin to learn how to break down an XSL file and understand what it's doing?
Problem: I produce a genealogy site for my family using (in part) a software program (Second Site) that takes data from my genealogy program (Master Genealogist, or TMG), massages it through XSL into HTML code.
I have access to the XSL and can change it... and want to... but haven't a CLUE what all the variables are.
In particular, here is the code for one type of output:
- <!-- Show Families with at least one child
-->
<xsl:variable name="family" select="family[count(child)>0]" />
- <xsl:if test="$family">
- <xsl:for-each select="$family">
- <!-- Show spouse/partner
-->
<xsl:variable name="children" select="child" />
- <DL>
- <DT>
<BR />
- <xsl:choose>
- <xsl:when test="count($children)=1">
<xsl:value-of select="$strchild" disable-output-escaping="yes" />
</xsl:when>
- <xsl:otherwise>
<xsl:value-of select="$strchildren" disable-output-escaping="yes" />
</xsl:otherwise>
</xsl:choose>
<xsl:text />
<xsl:apply-templates select="$prefself/name" />
- <xsl:if test="partner">
<xsl:text />
<xsl:value-of select="$strand" disable-output-escaping="yes" />
<xsl:text />
<xsl:apply-templates select="partner/pref" />
</xsl:if>
</DT>
- <DD>
- <!-- Show children
-->
- <xsl:for-each select="$children">
Using this code, I might get this output:
<DT><BR>Children of Mary Webb and <A HREF="p3.htm#i5"><SPAN CLASS=ng>David</SPAN> <SPAN CLASS=ns>Baker</SPAN></A></DT>
<DD><A HREF="p4.htm#i33"><SPAN CLASS=ng>Elizabeth</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1780<BR><A HREF="p4.htm#i34"><SPAN CLASS=ng>Thomas</SPAN> <SPAN CLASS=ns>Baker</SPAN></A><b>+</b> b. 24 May 1782<BR><A HREF="p4.htm#i35"><SPAN CLASS=ng>William</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1784<BR><A HREF="p5.htm#i95"><SPAN CLASS=ng>Nancy</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 31 Dec 1786, d. 15 Feb 1882<BR><A HREF="p5.htm#i36"><SPAN CLASS=ng>John Crittenden</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 27 Dec 1788<BR><A HREF="p5.htm#i37"><SPAN CLASS=ng>Mary</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 13 Oct 1792</DD>
which appears as:
Children of Mary Davenport and William Wiseman
Thomas Wiseman b. 30 Apr 1763
Dorothy Wiseman+ b. 5 Feb 1765, d. 23 Aug 1855
William Wiseman b. 5 Aug 1767
Mary Wiseman b. 11 Apr 1769
Davenport Wiseman b. 25 Aug 1771
Martin Wiseman b. 24 Aug 1773
James Wiseman b. 18 Aug 1775
John Wiseman b. 21 Feb 1777
Celestial Wiseman b. 22 Oct 1779
Susannah Wiseman+ b. 16 Dec 1781
Robert Wiseman b. 14 Jul 1784
And here is the code for another type of output for the same program:
- <!-- Show Families
-->
<xsl:variable name="family" select="family" />
- <xsl:if test="$family">
- <xsl:for-each select="$family">
- <!-- Show spouse/partner and tags
-->
<BR />
- <TABLE>
<xsl:call-template name="table-parameters" />
- <TR>
- <TD CLASS="g1">
- <B>
<xsl:value-of select="$strfamily" disable-output-escaping="yes" />
- <xsl:if test="count(../family)>1">
<xsl:text />
<xsl:value-of select="position()" />
</xsl:if>
</B>
</TD>
<TD CLASS="g2"> </TD>
- <TD CLASS="g3">
<xsl:apply-templates select="partner/pref" />
<xsl:text />
<xsl:apply-templates select="partner/lifespan" />
</TD>
</TR>
- <!-- Show children
-->
<xsl:variable name="children" select="child" />
- <xsl:if test="$children">
- <xsl:for-each select="$children">
- <TR>
- <TD CLASS="g1">
- <xsl:if test="position()=1">
- <xsl:choose>
- <xsl:when test="count($children)=1">
<xsl:value-of select="$strchild" disable-output-escaping="yes" />
</xsl:when>
- <xsl:otherwise>
<xsl:value-of select="$strchildren" disable-output-escaping="yes" />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:text> </xsl:text>
</TD>
- <TD CLASS="g2">
<xsl:value-of select="position()" />
.
</TD>
- <TD CLASS="g3">
<xsl:apply-templates select="pref" />
<xsl:text />
<xsl:apply-templates select="lifespan" />
</TD>
</TR>
</xsl:for-each>
</xsl:if>
</TABLE>
</xsl:for-each>
- <!-- family loop
-->
which produces this output:
<TABLE CLASS="grid"><TR><TD CLASS="g1"><B>Spouse</B></TD>
<TD CLASS="g2"> </TD>
<TD CLASS="g3"><A HREF="p3.htm#i5"><SPAN CLASS=ng>David</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 3 June 1749, d. 15 September 1838</TD></TR>
<TR><TD CLASS="g1">Children </TD>
<TD CLASS="g2">1.</TD>
<TD CLASS="g3"><A HREF="p4.htm#i33"><SPAN CLASS=ng>Elizabeth</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1780</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">2.</TD>
<TD CLASS="g3"><A HREF="p4.htm#i34"><SPAN CLASS=ng>Thomas</SPAN> <SPAN CLASS=ns>Baker</SPAN></A><b>+</b> b. 24 May 1782</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">3.</TD>
<TD CLASS="g3"><A HREF="p4.htm#i35"><SPAN CLASS=ng>William</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1784</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">4.</TD>
<TD CLASS="g3"><A HREF="p5.htm#i95"><SPAN CLASS=ng>Nancy</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 31 Dec 1786, d. 15 Feb 1882</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">5.</TD>
<TD CLASS="g3"><A HREF="p5.htm#i36"><SPAN CLASS=ng>John Crittenden</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 27 Dec 1788</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">6.</TD>
<TD CLASS="g3"><A HREF="p5.htm#i37"><SPAN CLASS=ng>Mary</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 13 Oct 1792</TD>
</TR>
</TABLE>
which looks like this:
Spouse David Baker b. 3 June 1749, d. 15 September 1838
Children 1. Elizabeth Baker b. 20 Apr 1780
2. Thomas Baker+ b. 24 May 1782
3. William Baker b. 20 Apr 1784
4. Nancy Baker b. 31 Dec 1786, d. 15 Feb 1882
5. John Crittenden Baker b. 27 Dec 1788
6. Mary Baker b. 13 Oct 1792
What I would like to do is produce the following:
Children with David Baker b. 3 June 1749, d. 15 September 1838
1. Elizabeth Baker b. 20 Apr 1780
2. Thomas Baker+ b. 24 May 1782
3. William Baker b. 20 Apr 1784
4. Nancy Baker b. 31 Dec 1786, d. 15 Feb 1882
5. John Crittenden Baker b. 27 Dec 1788
6. Mary Baker b. 13 Oct 1792
What in the world am I looking for??? (And, by the way, sometimes there will be only one child and it should say Child with rather than Children with...
Problem: I produce a genealogy site for my family using (in part) a software program (Second Site) that takes data from my genealogy program (Master Genealogist, or TMG), massages it through XSL into HTML code.
I have access to the XSL and can change it... and want to... but haven't a CLUE what all the variables are.
In particular, here is the code for one type of output:
- <!-- Show Families with at least one child
-->
<xsl:variable name="family" select="family[count(child)>0]" />
- <xsl:if test="$family">
- <xsl:for-each select="$family">
- <!-- Show spouse/partner
-->
<xsl:variable name="children" select="child" />
- <DL>
- <DT>
<BR />
- <xsl:choose>
- <xsl:when test="count($children)=1">
<xsl:value-of select="$strchild" disable-output-escaping="yes" />
</xsl:when>
- <xsl:otherwise>
<xsl:value-of select="$strchildren" disable-output-escaping="yes" />
</xsl:otherwise>
</xsl:choose>
<xsl:text />
<xsl:apply-templates select="$prefself/name" />
- <xsl:if test="partner">
<xsl:text />
<xsl:value-of select="$strand" disable-output-escaping="yes" />
<xsl:text />
<xsl:apply-templates select="partner/pref" />
</xsl:if>
</DT>
- <DD>
- <!-- Show children
-->
- <xsl:for-each select="$children">
Using this code, I might get this output:
<DT><BR>Children of Mary Webb and <A HREF="p3.htm#i5"><SPAN CLASS=ng>David</SPAN> <SPAN CLASS=ns>Baker</SPAN></A></DT>
<DD><A HREF="p4.htm#i33"><SPAN CLASS=ng>Elizabeth</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1780<BR><A HREF="p4.htm#i34"><SPAN CLASS=ng>Thomas</SPAN> <SPAN CLASS=ns>Baker</SPAN></A><b>+</b> b. 24 May 1782<BR><A HREF="p4.htm#i35"><SPAN CLASS=ng>William</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1784<BR><A HREF="p5.htm#i95"><SPAN CLASS=ng>Nancy</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 31 Dec 1786, d. 15 Feb 1882<BR><A HREF="p5.htm#i36"><SPAN CLASS=ng>John Crittenden</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 27 Dec 1788<BR><A HREF="p5.htm#i37"><SPAN CLASS=ng>Mary</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 13 Oct 1792</DD>
which appears as:
Children of Mary Davenport and William Wiseman
Thomas Wiseman b. 30 Apr 1763
Dorothy Wiseman+ b. 5 Feb 1765, d. 23 Aug 1855
William Wiseman b. 5 Aug 1767
Mary Wiseman b. 11 Apr 1769
Davenport Wiseman b. 25 Aug 1771
Martin Wiseman b. 24 Aug 1773
James Wiseman b. 18 Aug 1775
John Wiseman b. 21 Feb 1777
Celestial Wiseman b. 22 Oct 1779
Susannah Wiseman+ b. 16 Dec 1781
Robert Wiseman b. 14 Jul 1784
And here is the code for another type of output for the same program:
- <!-- Show Families
-->
<xsl:variable name="family" select="family" />
- <xsl:if test="$family">
- <xsl:for-each select="$family">
- <!-- Show spouse/partner and tags
-->
<BR />
- <TABLE>
<xsl:call-template name="table-parameters" />
- <TR>
- <TD CLASS="g1">
- <B>
<xsl:value-of select="$strfamily" disable-output-escaping="yes" />
- <xsl:if test="count(../family)>1">
<xsl:text />
<xsl:value-of select="position()" />
</xsl:if>
</B>
</TD>
<TD CLASS="g2"> </TD>
- <TD CLASS="g3">
<xsl:apply-templates select="partner/pref" />
<xsl:text />
<xsl:apply-templates select="partner/lifespan" />
</TD>
</TR>
- <!-- Show children
-->
<xsl:variable name="children" select="child" />
- <xsl:if test="$children">
- <xsl:for-each select="$children">
- <TR>
- <TD CLASS="g1">
- <xsl:if test="position()=1">
- <xsl:choose>
- <xsl:when test="count($children)=1">
<xsl:value-of select="$strchild" disable-output-escaping="yes" />
</xsl:when>
- <xsl:otherwise>
<xsl:value-of select="$strchildren" disable-output-escaping="yes" />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:text> </xsl:text>
</TD>
- <TD CLASS="g2">
<xsl:value-of select="position()" />
.
</TD>
- <TD CLASS="g3">
<xsl:apply-templates select="pref" />
<xsl:text />
<xsl:apply-templates select="lifespan" />
</TD>
</TR>
</xsl:for-each>
</xsl:if>
</TABLE>
</xsl:for-each>
- <!-- family loop
-->
which produces this output:
<TABLE CLASS="grid"><TR><TD CLASS="g1"><B>Spouse</B></TD>
<TD CLASS="g2"> </TD>
<TD CLASS="g3"><A HREF="p3.htm#i5"><SPAN CLASS=ng>David</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 3 June 1749, d. 15 September 1838</TD></TR>
<TR><TD CLASS="g1">Children </TD>
<TD CLASS="g2">1.</TD>
<TD CLASS="g3"><A HREF="p4.htm#i33"><SPAN CLASS=ng>Elizabeth</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1780</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">2.</TD>
<TD CLASS="g3"><A HREF="p4.htm#i34"><SPAN CLASS=ng>Thomas</SPAN> <SPAN CLASS=ns>Baker</SPAN></A><b>+</b> b. 24 May 1782</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">3.</TD>
<TD CLASS="g3"><A HREF="p4.htm#i35"><SPAN CLASS=ng>William</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 20 Apr 1784</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">4.</TD>
<TD CLASS="g3"><A HREF="p5.htm#i95"><SPAN CLASS=ng>Nancy</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 31 Dec 1786, d. 15 Feb 1882</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">5.</TD>
<TD CLASS="g3"><A HREF="p5.htm#i36"><SPAN CLASS=ng>John Crittenden</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 27 Dec 1788</TD>
</TR>
<TR><TD CLASS="g1"> </TD>
<TD CLASS="g2">6.</TD>
<TD CLASS="g3"><A HREF="p5.htm#i37"><SPAN CLASS=ng>Mary</SPAN> <SPAN CLASS=ns>Baker</SPAN></A> b. 13 Oct 1792</TD>
</TR>
</TABLE>
which looks like this:
Spouse David Baker b. 3 June 1749, d. 15 September 1838
Children 1. Elizabeth Baker b. 20 Apr 1780
2. Thomas Baker+ b. 24 May 1782
3. William Baker b. 20 Apr 1784
4. Nancy Baker b. 31 Dec 1786, d. 15 Feb 1882
5. John Crittenden Baker b. 27 Dec 1788
6. Mary Baker b. 13 Oct 1792
What I would like to do is produce the following:
Children with David Baker b. 3 June 1749, d. 15 September 1838
1. Elizabeth Baker b. 20 Apr 1780
2. Thomas Baker+ b. 24 May 1782
3. William Baker b. 20 Apr 1784
4. Nancy Baker b. 31 Dec 1786, d. 15 Feb 1882
5. John Crittenden Baker b. 27 Dec 1788
6. Mary Baker b. 13 Oct 1792
What in the world am I looking for??? (And, by the way, sometimes there will be only one child and it should say Child with rather than Children with...