You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Jeff Turner <je...@apache.org> on 2002/11/17 01:18:10 UTC
Skins refactored (Re: cvs commit:..)
On Sat, Nov 16, 2002 at 08:58:13PM -0000, jefft@apache.org 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:
dotdots.xsl
pathutils.xsl
renderlogo.xsl
split.xsl
tabutils.xsl
As well as:
book2menu.xsl
document2html.xsl
site2xhtml.xsl
tab2menu.xsl
And a few shared images in images/, like printer.gif and
built-with-forrest-button.png
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 -->
</xsl:template>
(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">
<xsl:apply-imports/>
</div>
</xsl:template>
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.
--Jeff
Re: Skins refactored (Re: cvs commit:..)
Posted by Jeff Turner <je...@apache.org>.
On Sun, Nov 17, 2002 at 11:30:03AM +1100, Peter Donald wrote:
..
> > 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:
>
> I noticed that you left a bunch of the files still in skin directory (split,
> renderlog, dotdots etc). Is there a reason for this?
Too many hours awake.. thanks, fixed.
--Jeff
Re: Skins refactored (Re: cvs commit:..)
Posted by Peter Donald <pe...@apache.org>.
On Sun, 17 Nov 2002 11:18, Jeff Turner wrote:
> On Sat, Nov 16, 2002 at 08:58:13PM -0000, jefft@apache.org 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:
I noticed that you left a bunch of the files still in skin directory (split,
renderlog, dotdots etc). Is there a reason for this?
--
Cheers,
Peter Donald
*-----------------------------------------------------*
* "Faced with the choice between changing one's mind, *
* and proving that there is no need to do so - almost *
* everyone gets busy on the proof." *
* - John Kenneth Galbraith *
*-----------------------------------------------------*