Re: [xsl] Headers 'n Footers 'n XSL

Subject: Re: [xsl] Headers 'n Footers 'n XSL
From: Arni J Rognvaldsson <arni.rognvaldsson@xxxxxxxxxx>
Date: Tue, 20 Mar 2001 16:34:45 -0500
Hi,

Assuming your XML looks like this:

<doc>
        <foo>
        </foo>
</doc>

Your XSL for individual pages could look something like this:

<?xml version="1.0"?>
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html"/>
<xsl:include href="header_footer.xsl"/>

<xsl:template match="doc">
...
</xsl:template>
</xsl:stylesheet>

And your common header_footer.xsl something like this:

<?xml version="1.0"?>
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html"/>

<xsl:template match="/">
        [header here]
        <xsl:apply-templates select="doc"/>
        [footer here]
</xsl:template>
</xsl:stylesheet>

I'm sure this can be improved on some, but at least it works. The interesting part is that from a file perspective, your individual pages include the header/footer, but from an XSL perspective you can think of the header_footer page including the other pages.

Arni

At 01:08 PM 3/20/2001 -0800, you wrote:
Howdy,

I was wondering if anybody on this list has ever worked with headers and
footers and XSL. What I mean is that you have a site or an app that has the
same header, the same footer but the content differs in the middle. What I'd
like to do is have xsl for the particular pages that are getting generated
but call an external source for the header and footer so as to not recreate
the same html all over again. Makes it easy to update headers and footers
too.

I did this in the past when the XSL spec was in its infancy but since then
it doesn't seem like there's an easy way to do this. I was thinking
<xsl:import> or <xsl:include>

Any ideas?

Thanks,

Jon


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