[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XHTML templating (best method)


Subject: Re: [xsl] XHTML templating (best method)
From: Kris Leech <krisleech@xxxxxxxxxxxxxxx>
Date: Fri, 26 Jan 2007 14:57:28 +0000

David Carlisle wrote:

By the way how do relative paths work in includes are they relative to
the template with the include?



You can not have an xsl:include inside a template (your second example
is a syntax error).


Okay, thanks. So that will not work, not the way I have it anyway.



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.



sorry I didn't understand why you needed a temporary file here, or what
you mean by the [/FILE] syntax.


I just used [FILE] to show that the first example was one file (two files merged in to one) and the second example was two seperate files. I should have pointed that out. They where not supposed to be part of the XSLT code.

The usual way of sharing common features such as head and foot amongst
multiple stylesheets is you put teh common features in a common
stylesheet and each of the page-specific stylesheets import teh common
core (with the import being a top level instruction, not inside a
template)


Something like this?

[FILE]
<xsl:include href="view.xsl" />
<xsl:template match="/">
<html>
<body>
<h2>This is the layout</h2>
<xsl:template match="/view">
</body>
</html>
</xsl:template>
[/FILE]

[FILE]
<xsl:template match="view">
<h3>This the view</h3>
<xsl:value-of select="/a"/>
<xsl:value-of select="/b"/>
</xsl:template>
[/FILE]

In this example like the others I would need to create a temp file because view.xsl will not be the real filename of the imported stylesheet. It will be a different filename for every URL.
eg.


abc.com/dothis.htm
abc.com/dothat.htm

Both URL's use the same layout, but both have a different 'view', so
<xsl:include href="view.xsl" /> needs to be replaced by <xsl:include href="dothis.xsl" /> or <xsl:include href="dothat.xsl" /> depending on which URL is requested.


I hope that makes sense?

David


Current Thread
Keywords