Altova Mailing List Archives
>xsl-list Archive Home
>Thread Prev - [xsl] XHTML templating (best method)
Re: [xsl] XHTML templating (best method)
Date: 1/29/2007 10:10:00 AM
Kris, Have you considered Eric van der Vlist's idea of "style-free stylesheets"  ? I've used this technique in several projects. The main benefit is that you can give the (pure) HTML template to a graphic designer while you concentrate on the "code" (XSLT). It's really MVC for XSLT, where XML is the model, HTML template the view, and XSLT the controller. Cheers, Antony  http://www.xml.com/pub/a/2000/07/26/xslt/xsltstyle.html (original article)  http://eric.van-der-vlist.com/blog/2368_The_influence_of_microformats_on_style-free_stylesheets.item (update) Kris Leech wrote: Hello, What is the best way to setup a XHTML templating system so that I have the concept of outer layout template and inner view template. The outer layout would contain the usual header, footer & navigation div's that would be same on every page. The inner view would be the template that actually transformed the XML data, and so different for every page. I can think of a few ways to do this myself (below), is there a standard or commonly used way of doing this? Are there any gotcha's in my reasoning below, other than that they both require creating a temporary file which would need a random filename. 1.) Append the 'view' template under the 'layout' template to make a temporary file [FILE] <xsl:template match="/"> <html> <body> <h2>This is the layout</h2> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="content"> <h3>This the view</h3> <xsl:value-of select="/a"/> <xsl:value-of select="/b"/> </xsl:template> [/FILE] Using this method the XML would need to constructed in such a way that there was a root node containing a content node. 2.) The 'layout' template has an include/import. The problem is the filename of the 'view' template is different every time so I would either need to parse the layout template for the include filename and replace it with the correct one, again this would involve creating a temporary file. [FILE] <xsl:template match="/"> <html> <body> <h2>This is the layout</h2> <xsl:include href="view.xsl" /> </body> </html> </xsl:template> [/FILE] [FILE] <h3>This the view</h3> <xsl:value-of select="/a"/> <xsl:value-of select="/b"/> [/FILE] By the way how do relative paths work in includes are they relative to the template with the include? Many thanks, K.