Re: [xsl] Rescuing XSLT from Niche Status

Subject: Re: [xsl] Rescuing XSLT from Niche Status
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sat, 17 Feb 2001 01:09:42 GMT
> This a common theme I've seen from a number of responses.
I think the largely negative response is rather generated by the initial
posting advertising this as a new view on xslt and the "rescuing"
terminology. If you'd have described it as using pull techniques and
literal element as stylesheets as a very simple way to get beginners
started I think you'd have seen general agreement. 

> No I mean, you might want your "chapter/title" to be an <h2> at the top of
> the chapter but you might want it to be <h4> in the table of contents.    

Oh so

match="title" ... <h2> ..
match="title"  mode ="toc" ... <h4> ..

I don't find that people have any problem grasping the basic idea of
modes: that if you want two styles of transform you have two modes.

But I'd say that any document complex enough to require a TOC then
probably the pull method is not very attractive. Unless you know the
exact depth of sectioning etc how can you make your skeleton template?

Far easier to just define some templates defining locally the transforms
you want and recurse down with apply-templates. Then your table of
contents automatically grows to fit whatever's in the document.

The main danger of the "pull" technique is that you lose data very
easily: the default behaviour is to lose all the input document. You
have to explicitly code to copy things over. 
Conversely using templates the default behaviour is not to lose so much.
I usually just start off with a deafault template something like
<xsl:template match="*">
 <font color="red">[<xsl:value-of select="name()"/>]</font>

Then just throw in templates as needed until the red its go away,
(Of course I should say that first I fully specify and prove correct the
entire design before starting to code the stylesheet but....)

Now of course this only works if the input is in some sense already a
document. If the input is a few GByte of database, having an initial
pass at writing a stylesheet have the whole thing come out in red is not
so attractive. I suppose this is down to differing viewpoints again.

It's this facility to independently code small chuncs of stuff (which
XSLT shares with many functional programming environments such as
Standard ML, or lisp) that makes it rather attractive. Just coding the
entire thing as one monolithic chunk works but just looks dull I think
(in terms of showing students any interseting behaviour)


This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit

 XSL-List info and archive:

Current Thread