RE: [xsl] nested templates?

Subject: RE: [xsl] nested templates?
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Wed, 16 May 2001 21:49:18 +0100
Thomas,
I think that is a completely bad example. That is completely flat and
doesn't give any insight into anything. You might as well have just used
goto for all the stucture there is in it.

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Thomas B.
>Passin
>Sent: 16 May 2001 21:17
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: Re: [xsl] nested templates?
>
>
>[Alex Black]
>
>> >> is it possible to construct an xslt stylesheet that is more similar to
>a
>> >> "complete" page, i.e. with nested templates:
>> >
>> > It is possible to design a "complete page" this is what is sometimes
>> > called the pull method, in fact if you are doing that, you don't need
>> > any xsl;template instructions at all, see the XSLT spec for an example
>> > (or the FAQ for this list).
>>
>> I've seen that faq and _all_ of the examples are:
>>
>> xsl:stylesheet
>>
>> xsl:template
>> xsl:apply-templates
>>
>> xsl:template
>>
>> xsl:template
>>
>> .. ad infinum.
>>
>> -- this is the "lots of little bits" method, which is not useful for
>> production.
>>
>
>[Tom]
>Too many "little bits" can be hard to manage and understand, but you should
>remember that some  key principles of modern programming are to modularize,
>encapsulate parts, minimize their interactions, and restrict the number of
>things one part does.  Don't think for a minute that generating a page by
>transforming a document with a stylesheet isn't programming!
>
>I'm not sure what you got out of those FAQs, or just what you want to do,
>but let me sketch out a middle way you could build an html page which
>clearly shows the main components but keeps their implementation separated
>and also clear.  Of course, this will only be a sketch to show the idea.
>Please forgive the length of this post.
>
>Even without any documentation, or seeing the source xml, this stylesheet
>makes it clear what the page layout is and what is supposed to go on.  I
>think such a stylesheet is clear, and easy to change.  Just fine for
>production.  What more could a person want?  Fully nested templates would
>make it harder, not easier, to design and maintain the page.
>
>Cheers,
>
>Tom P
>
><?xml version="1.0"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
><xsl:output method='html'/>
>
><!-- The source document specifies xml filenames for different xml
>files for
>the style,
>navigation panel, content panel, and footer panel.  Of course, they
>could be in the same document as well.-->
>
><xsl:variable name='style' select='document(/page/style)'/>
><xsl:variable name='nav' select='document(/page/nav)'/>
><xsl:variable name='content' select='document(/page/content)'/>
><xsl:variable name='footer' select='document(/page/footer)'/>
>
><!--========MAIN PAGE LAYOUT =====-->
><xsl:template match="/">
><html><title>Demo Page</title>
><head>
><style><xsl:call-template name='css'/></style>
></head>
>
><body>
><table><tr><td><xsl:call-template name='left-hand-column'/></td>
>   <td>xsl:call-template name='right-hand-column'/></td>
>  </tr>
></table>
><div class='footer'><xsl:call-template name='footer'/></div>
>
></body>
></html>
></xsl:template>
><!--==============================-->
>
><!--============= CSS Style directives ==============-->
><xsl:template name='css'>
> <!-- Use xsl:for-each to set the context to the style document-->
> <xsl:for-each select='$style'>
>  body {background-color:<xsl:value-of select='skincolor'/>}
>  <!-- More css commands would go here -->
> </xsl:for-each>
></xsl:template>
><!--==============================-->
>
><!--============ Left hand panel ============-->
><xsl:template name='left-hand-column'>
> <!-- Use xsl:for-each to set the context to the navigation bar document-->
> <xsl:for-each select='$nav'>
>  <!-- xsl instructions to build the
>  left-hand navigation panel would go here -->
> </xsl:for-each>
></xsl:template>
><!--==============================-->
>
><!-- Use the same approach for the other components-->
>
></xsl:stylesheet>
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread