I developed a way of "callback" templates. Look at this:

(0) consider a HTML design like this:

+--------------------------------------------+
| Page Title (each page different)           |
+--------------------------------------------+
| Main Navigation (for all pages the same    |
+--------------------------------------------+
|                                            |
|                                            |
| Content (each page different)              |
|                                            |
|                                            |
|                                            |
+--------------------------------------------+
| Footer (each page different)               |
+--------------------------------------------+


(1) first of all there is the default.xsl stylesheet it looks (very reduced version) like this:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; encoding="iso-8859-1" version="1.0">

<xsl:variable name="menu" select="document('../xml/menu.xml')"/>

   <xsl:template match="/">
       <html>
           <head>
               <title>Cocoon Day 2003</title>
               <link href="style.css" rel="stylesheet" type="text/css" />
           </head>

           <body>
           <!-- snip: here is the html part for the navigation header -->
           <xsl:call-template name="title"/>
           <!-- end of html navigation part -->

<!-- / snip here is the html part surrounding the content -->
<xsl:apply-templates /> oder <xsl:call-template name="content"/>
<!-- end of html content part -->


           <!-- / snip here is the html part surrounding the footer -->
           <xsl:call-template name="footer"/>
           <!-- end of html content part -->

           </body>
       </html>
   </xsl:template>

</xsl:stylesheet>


(2) then there are the specific stylesheets for different parts of the website, looking like this:


<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   encoding="iso-8859-1"
   version="1.0">

<xsl:include href="default.xsl"/>

   <xsl:template name="title">
       Titel
   </xsl:template>

   <xsl:template name="content">
       <!-- add XSL and other code to generate content part -->
   </xsl:template>

<xsl:template name="footer">
<!-- add XSL and other code to generate footer part -->
</xsl:template>
</xsl:stylesheet>



the include includes the default stylesheet, in which the root template it the first to be executed. then, this root template builds the HTML "frame" and calls the named templates to fill in the concrete content.


The main advantage is this: in the default.xsl stylesheet inside the root template is xhtml that can be edited with any editor e.g. dreamweaver. the only xsl tags are the 2 or 3 call-templates and those are usually ignored by html editors like dreamweaver.

I use this in many projects and it works excellent also offline (with normal XSLT transformation e.g. using ANT).

alex


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to