[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with xsl:template using XSLT 1.0

Subject: Re: Problem with xsl:template using XSLT 1.0
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Wed, 5 Dec 2007 17:24:20 +0000
Re:  Problem with xsl:template using XSLT 1.0
On 05/12/2007, Scott Trenda <Scott.Trenda@xxxxxxxx> wrote:
> This received a lot more replies than I had initially expected. :/
>
> I gave that advice to start with because I thought it would ensure that
> he'd avoid context-dependent expressions in his match patterns. From
> what I've been reading in the replies, there seems to be a lot of
> personal coding style decisions that can lead to several different but
> functionally equivalent stylesheets in the end. Myself, I like to have
> more control over my output document, and so I only let the default
> behavior take over when I know it'll do exactly what I want. Generally
> it's as simple as starting with a root-match template and applying
> templates selectively.
>
> Could this thread die now? Seems we're kind of chasing our tails here.

There's an important design principle here though.  Because coding
XSLT is still maturing most developers will be writing code from
scratch rather than maintaining old code.  As the amount of XSLT grows
maintainability will become an issue.

Given a stylesheet and the task of modifying its behaviour, if the
stylesheet has been written in a certain way you can simply import it
and override the appropriate template, without needing to modify the
original stylesheet.

If the code is hidden within a template, then you either replicate the
whole template and change you part you need, or modify the original.

Most of the XSLT I've written takes the form of at least one
"common.xslt"and then a number of specific stylesheets for each
variation import common:

specific1
specific2

etc

and even then I've had requirements to modify a specifc stylesheet
because one customer wants exactly the same as another customer, but
with minor changes.  This is a 2 minute job with the right structure.

What I've learnt over the years of implementing this pattern over and
over again is that in common.xslt, and even the specific stylesheets,
is to code to allow behaviour to be overridden.  The amount of times
I've had to go back and rewrite templates in common so it calls
templates instead of just outputting code... the most basic form is:

<img src="logo.gif"/>

becomes:

<xsl:call-template name="logo"/>

...where the "logo" named template only exists in the specific stylesheets.

If everything is done right, adding support for a new customer is just
a case of adding a new stylesheet containing just the code specific to
them.

This is why I like the idea of the no-op templates, as it gives you a
chance to override the behaviour.

cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.