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

XHTML templating (best method)

Subject: XHTML templating (best method)
From: Kris Leech <krisleech@xxxxxxxxxxxxxxx>
Date: Fri, 26 Jan 2007 10:23:18 +0000
 XHTML templating (best method)
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.


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.