Yes, and in fact this is one of the strengths of XSLT, that you can put 'top 
bit' and 'bottom bit' in the same place, and its syntactically impossible to 
mismatch them in the course of maintenance.

I've gone a bit further with this idea as well. Each of my pages calls an HTML 
generator XSLT as its last stylesheet, its structure is something like:

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#160;">]>

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

        <xsl:include href="/modules/community/html.xsl"/>
        <xsl:include href="/templates/test1_html.xsl"/>
</xsl:stylesheet>
( I've elided some namespaces and other includes for clarity)

test1_html.xsl looks like this:
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#160;">]>

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

        <xsl:output method="html" />

        <xsl:template match="/">
                <HTML>
                        <HEAD>
                                <link REL="stylesheet" href="/public.css" 
TYPE="text/css"/>
                                <xsl:apply-templates 
select="/page/contents/pagetitle/*"/>
                        </HEAD>
                        <BODY class="body">
                                <table class="bodytable">
                                        <tr>
                                                <td valign="top">
                                                        <table class="leftside">
                                                                <xsl:apply-templates 
select="/page/contents/leftside/**/>
                                                        </table>
                                                </td>
                                                <td valign="top">
                                                        <xsl:apply-templates 
select="/page/contents/center/*"/>
                                                </td>
                                        </tr>
                                </table>
                        </BODY>
                </HTML>
        </xsl:template>

</xsl:stylesheet>

Now everything I want on the 'left side' of my page is found in 
/page/contents/leftside/whatever tags in the XML I'm processing. In my HTML 
generator stylesheet I can have additional templates that match elements 
found in these sections which would be side navigation, etc and convert them 
into chunks of HTML. Naturally all these can be seperate chunks that my page 
generator stylesheet gets with <xsl:import/>. 

The other possibility would be to structure it so that HTML is generated 
incrementally and each type of component such as navigation is a seperate 
stylesheet in a long pipeline, with namespaces ensuring that each stage 
processes only what its supposed to. That WOULD have the advantage of letting 
you mix SAX, XPS, and XSLT transforms more flexibly.

On Saturday 08 February 2003 09:00 am, Matt Sergeant wrote:
> A strange XSLT thing is bugging me...
>
> In XPathScript because it's not XML I can create unbalanced component
> pieces, so I can basically have:
>
> 1. TOP BIT
> 2. CUSTOM Per-Page BIT
> 3. content
> 4. CUSTOM Per-Page BIT
> 5. BOTTOM BIT
>
> I can't do that in XSLT because everything has to be balanced (xml tag
> wise). So I was wondering what people use to create this effect? The
> way I was thinking was a named template call in a standard template
> implementing 1 and 5, and calling a named template for 2,3,4. The named
> template is in the XSLT that includes the "/" template.
>
> So something like this:
>
> global.xsl:
> <xsl:template match="/">
> <html>
>    <head>...</head>
>    <body>
>      <div something>
>        <xsl:call-template name="main-content"/>
>      </div>
>    </body>
> </html>
> </xsl:template>
>
> foo.xsl:
> <xsl:include href="global.xsl"/>
> <xsl:template name="main-content">
>    <!-- custom header here -->
>    <xsl:apply-templates/>
>    <!-- custom footer here -->
> </xsl:template>
>
> So the question is - does this work?
>
> Matt.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Tod Harter
Giant Electronic Brain

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

Reply via email to