forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <>
Subject Skins refactored (Re: cvs commit:..)
Date Sun, 17 Nov 2002 00:18:10 GMT
On Sat, Nov 16, 2002 at 08:58:13PM -0000, wrote:
> jefft       2002/11/16 12:58:13
>   Modified:    .        status.xml
>                src/resources/skins/avalon-tigris/xslt/html book2menu.xsl
>                         document2html.xsl site2xhtml.xsl tab2menu.xsl
>                src/resources/skins/forrest-site/xslt/html book2menu.xsl
>                         document2html.xsl site2xhtml.xsl tab2menu.xsl
>   Added:       src/resources/skins/common/xslt/html book2menu.xsl
>                         document2html.xsl dotdots.xsl pathutils.xsl
>                         renderlogo.xsl site2xhtml.xsl split.xsl
>                         tab2menu.xsl tabutils.xsl
>   Log:
>   Factored out common structural stuff into reusable XSLTs, leaving just
>   presentational XSLT in each skin.

As per our lazy friend, Consensus, I've committed a large refactoring of
the skins.  There is now a src/resources/skins/common directory
containing reusable library XSLTs in xslt/html:


As well as:


And a few shared images in images/, like printer.gif and

The second set of XSLTs contains all the 'structural' XSLT in skins, and
anything else common.  Each skin then <xsl:import>'s the common
equivalent, and only overrides what it needs.

There are two patterns implemented:

'template pattern' (GoF)
  book2menu.xsl, tab2menu.xsl
  For example, tab2menu.xsl has some intricate logic to determine when
  a tab is 'on'.  Rather than replicate this in each skin, it is kept
  in common/, and <xsl:call-template> calls are made to 'selected' and
  'not-selected' templates, defined by real skin's tab2menu.xsl.

Straight inheritance
  document2html.xsl, site2xhtml.xsl

One of XSLT's Really Cool features is that stylesheets can emulate OOP
inheritance with <xsl:import> and <xsl:apply-imports/>.

  Eg, in avalon-tigris's document2html.xsl, we first inherit all the
  common rules:

  <xsl:import href="../../../common/xslt/html/document2html.xsl"/>

  and then either redefine ones we don't like:

  <xsl:template name="pdflink">
    <!-- No PDFs thankyou -->

  (actually there's a bit of template method creeping in there too)

  or override and do the XSLT equivalent of a super() call:

  <xsl:template match="section">
    <div class="section">

The overall effect is to make skins _much_ more maintainable, and adding
new skins like Miles' is less painful.

Because the 'common' directory is on the same level as other skins, it
can be used as a skin itself.  This is handy for testing changes
affecting all skins, without having to deal with any specifically.  The
'common' pseudo-skin looks pretty similar to the old 'basic' skin, which
is why I removed 'basic'.

There are probably bugs and oversights.. as people implement more skins,
please report back any changes needed in the common XSLTs.


View raw message