DTP


 
Lively discussions on the graphic arts and publishing — in print or on the web


Go Back   Desktop Publishing Forum > General Discussions > Web Site Building & Maintenance

Reply
 
Thread Tools Display Modes
Old 09-10-2005, 10:50 AM   #1
jgr
Member
 
Join Date: Dec 2004
Posts: 269
Default Deciphering XSL...

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:


Code:
- <!--  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:

Code:
<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:

Code:
- <!--  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:

Code:
<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...

   
__________________
-- jgr

Last edited by jgr; 09-10-2005 at 11:41 AM. Reason: it's XSL, not XLS!!
jgr is offline   Reply With Quote
Old 09-10-2005, 11:30 AM   #2
ktinkel
Sysop
 
ktinkel's Avatar
 
Join Date: Oct 2004
Location: In Connecticut, on the Housatonic River near its mouth at Long Island Sound.
Posts: 10,610
Default

Quote:
Originally Posted by jgr
How can I begin to learn how to break down an XLS file and understand what it's doing?

What in the world am I looking for???
I know from nuthin’ — but I believe this is the native format of MS Excel. Wonder what happens if you open your .xls file in Excel? (Or if you even can — might need to export in pure .xls formt.)

I hope someone who really knows will come along right about now …

   
__________________
::
ktinkel is offline   Reply With Quote
Old 09-10-2005, 11:40 AM   #3
jgr
Member
 
Join Date: Dec 2004
Posts: 269
Default

DUMB DUMB DUMB DUMB. I am SOOOOOO dumb. I just changed the name of this thread to "deciphering XSL" which is the web format and NOT XLS, which is the Excel format...

Sigh...

Sometimes I am just soooooooo dumb.

   
__________________
-- jgr
jgr is offline   Reply With Quote
Old 09-10-2005, 11:42 AM   #4
ktinkel
Sysop
 
ktinkel's Avatar
 
Join Date: Oct 2004
Location: In Connecticut, on the Housatonic River near its mouth at Long Island Sound.
Posts: 10,610
Default

Quote:
Originally Posted by jgr
DUMB DUMB DUMB DUMB. I am SOOOOOO dumb. Would you please change the name of this thread to "deciphering XSL" which is the web format and NOT XLS, which is the Excel format?
Oh, of course. (And you think you’re dumb? How ’bout me, huh? <g> I mean, you had it exactly right in the body of the message.

[sigh indeed]

   
__________________
::
ktinkel is offline   Reply With Quote
Old 09-10-2005, 11:42 AM   #5
jgr
Member
 
Join Date: Dec 2004
Posts: 269
Default

Quote:
Originally Posted by ktinkel
Oh, of course. (And you think you’re dumb? How ’bout me, huh? <g>
I fixed it, I think, but please double check for me. Gads, I feel soooooooooooo dumb.

   
__________________
-- jgr
jgr is offline   Reply With Quote
Old 09-10-2005, 08:20 PM   #6
Ian Petersen
Staff
 
Join Date: Nov 2004
Posts: 235
Default

Quote:
How can I begin to learn how to break down an XSL file and understand what it's doing?
Well, the best place to start is probably w3.org:

http://www.w3.org/Style/XSL/

It's pretty hairy stuff though. Most computer book stores have several shelves full of XSL/XSLT books. Since most of them seem to be somewhere around 1000 pages for the 'getting started' volume I fear they are not for the faint of heart. <g>

   
__________________
Ian
Ian Petersen is offline   Reply With Quote
Old 09-11-2005, 10:38 AM   #7
jgr
Member
 
Join Date: Dec 2004
Posts: 269
Default

Hmmm... it may be even harder considering the coding on that W3 page!
Attached Thumbnails
Click image for larger version

Name:	oops.gif
Views:	92
Size:	6.5 KB
ID:	191  

   
__________________
-- jgr
jgr is offline   Reply With Quote
Old 09-11-2005, 11:43 AM   #8
ktinkel
Sysop
 
ktinkel's Avatar
 
Join Date: Oct 2004
Location: In Connecticut, on the Housatonic River near its mouth at Long Island Sound.
Posts: 10,610
Default

Quote:
Originally Posted by jgr
Hmmm... it may be even harder considering the coding on that W3 page!
Oooh — very confidence-inspiring! (Not.)

   
__________________
::
ktinkel is offline   Reply With Quote
Old 09-11-2005, 02:15 PM   #9
jgr
Member
 
Join Date: Dec 2004
Posts: 269
Default

Quote:
Originally Posted by ktinkel
Oooh — very confidence-inspiring! (Not.)
And of all places to foul up -- w3.org. Geez... (Then again I suppose I can always feel better about my own CSS -- hey, if w3.org can't get it right, who am I to think I can???)

   
__________________
-- jgr
jgr is offline   Reply With Quote
Old 09-11-2005, 04:24 PM   #10
ktinkel
Sysop
 
ktinkel's Avatar
 
Join Date: Oct 2004
Location: In Connecticut, on the Housatonic River near its mouth at Long Island Sound.
Posts: 10,610
Default

Quote:
Originally Posted by jgr
And of all places to foul up -- w3.org. Geez... (Then again I suppose I can always feel better about my own CSS -- hey, if w3.org can't get it right, who am I to think I can???)
Good question.

I think you should rest easy! <g>

   
__________________
::
ktinkel is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:36 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Contents copyright 2004–2009 Desktop Publishing Forum and its members.