xsl-list
[Top] [All Lists]

RE: Streamline xslt

2002-09-26 05:14:48
Thanks Robert. This makes some sense. It seems similar to what the
Fusebox methodology uses for layouts. Have you found this to be flexible
enough for completely different html based designs? I am no sure that it
is flexible enought. It may be, I'm just not sure. I will give this a
try and let everyone know how it works.




On Wed, 2002-09-25 at 13:08, Robert Koberg wrote:
Hi,

Why not use xsl:include?

I like to keep all of my xsl:includes, variables and params in a global
definitions XSL. This is included in each primary/main XSLT. An example of a 2
column layout:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <!--
basic_2col.xsl  - A basic 2 column layout
===========
This is a primary stylesheet. Each primary stylesheet includes
global_definitions.xsl,
which in turn includes the common XSL pages. Much of the layout can be 
affected
just
by changing the /css/project.css. When a page is requested/generated, a source
XML
(always /WEB-INF/styling/site.xml) is transformed against a primary XSL -->
  <!-- *********** GLOBAL DEFINITIONS ************ -->
  <!-- global_definitions.xsl includes the common XSL templates, gathers
parameters sent in
from  the server and sets up common global variables. -->
  <xsl:include href="global_definitions.xsl"/>
  <xsl:variable name="root_relative" select="'false'"/>
  <!-- match the document root to start setting up the HTML page structure -->
  <xsl:template match="/">
    <html>
      <!-- *********** HTML HEAD ************ -->
      <!-- call to head.xsl to set up the HTML HEAD -->
      <xsl:call-template name="head"/>
      <body onload="{$body_onload_call}">
        <!-- *********** BANNER (top of the page) ************ -->
        <!-- call to banner.xsl to set up the top part of the page -->
        <xsl:call-template name="banner"/>
        <!-- *********** START MAIN LEFT COLUMN ************ -->
        <!-- ======================================= -->
        <div id="leftcol">
          <!-- ======== NAVIGATION? ======== -->
          <!-- if the /WEB-INF/styling/site.xml has it's /config/@nav_col set
to... -->
          <xsl:if test="$nav_col='narrow_left' or 
$nav_col='tabs_narrow_left'">
             <xsl:call-template name="nav"/>
          </xsl:if>
          <!-- ======== LEFT COLUMN CONTENT ======== -->
          <!-- applying templates on the folder's center column content and 
then
the
              page's center column content. The match happens in find_xml.xsl.
Normally,
              find_xml.xsl does not need to be altered. After the XML file is
found it proceeds
              to the article.xsl template which you might want to alter.-->
          <div class="floater">
            <xsl:apply-templates
select="$folder_nodeset/col[(_at_)type='narrow_left']" mode="main_content"/>
            <xsl:apply-templates 
select="$page_nodeset/col[(_at_)type='narrow_left']"
mode="main_content"/>
          </div>
          <br clear="all"/>
        </div>
        <!-- ======================================= -->
        <!-- *********** END MAIN RIGHT COLUMN ************ -->
        <!-- *********** START MAIN CENTER COLUMN ************ -->
        <!-- ======================================= -->
        <div id="centercol2left">
          <!-- ======== SNAIL TRAIL ? ======== -->
          <!-- Does the current page's folder properties indicate there should
be a snailtrail? -->
          <xsl:if test="$folder_nodeset/@snailtrail='true'">
            <xsl:call-template name="snailtrail"/>
          </xsl:if>
          <!-- ======== PAGER TOP ? ======== -->
          <!-- Does the current page's folder properties indicate there should
be
              a pager (i.e ' prev 1 2 3 n next ') above the content? -->
          <xsl:if test="$folder_nodeset/@pager='true'">
            <br clear="all"/>
            <xsl:call-template name="pager"/>
          </xsl:if>
          <!-- ======== PRINT FRIENDLY ======== -->
          <!-- Does the current page's properties indicate there should be a
print friendly link
              showing on the page? -->
          <xsl:if test="$page_nodeset/@print_friendly='true'">
            <br clear="all"/>
            <xsl:call-template name="pf_link"/>
          </xsl:if>
          <!-- ======== NAVIGATION? ======== -->
          <!-- if the /WEB-INF/styling/site.xml has it's /config/@nav_col set
to...  -->
              <xsl:if test="$nav_col='wide_center'">
                      <xsl:call-template name="nav"/>
              </xsl:if>
          <!-- ======== CENTER COLUMN CONTENT TABLE OF CONTENTS? ======== -->
          <!-- Does the current page's properties indicate there should be a
table of contents? -->
          <xsl:if test="$page_nodeset/@toc='true'">
            <xsl:call-template name="toc"/>
          </xsl:if>
          <!-- ======== CENTER COLUMN CONTENT ======== -->
          <!-- applying templates on the folder's center column content and 
then
              the page's center column content. The match happens in
find_xml.xsl.
              Normally, find_xml.xsl does not need to be altered. After the 
XML
file is
              found it proceeds to templates which you might want to alter -->
          <xsl:apply-templates 
select="$folder_nodeset/col[(_at_)type='wide_center']"
mode="main_content"/>
          <xsl:apply-templates 
select="$page_nodeset/col[(_at_)type='wide_center']"
mode="main_content"/>
          <!-- ======== FOLDER INDEXER ======== -->
          <!-- Does the current page's folder properties indicate there should
be a
              pager (i.e ' prev 1 2 3 n next ') below the content? [same as
above] -->
          <xsl:if test="$folder_nodeset/@index='true'">
            <xsl:call-template name="indexer"/>
          </xsl:if>
          <!-- ======== PAGER BOTTOM ? ======== -->
          <!-- Does the current page's folder properties indicate there should
be a
              pager (i.e ' prev 1 2 3 n next ') below the content? [same as
above] -->
          <xsl:if test="$folder_nodeset/@pager='true'">
            <br clear="all"/>
            <xsl:call-template name="pager"/>
          </xsl:if>
          <!-- ======== CENTER COLUMN CONTENT METADATA? ======== -->
        <!-- Does the current page's properties indicate there should be a
metadata
                  showing on the page? -->
        <xsl:if test="$page_nodeset/@metadata='true'">
          <xsl:call-template name="metadata"/>
        </xsl:if>
          <br clear="all"/>
        </div>
        <!-- ======================================= -->
        <!-- *********** END MAIN CENTER COLUMN ************ -->
        <br clear="all"/>
        <xsl:call-template name="footer"/>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]On Behalf Of 
Geoff
Sent: Wednesday, September 25, 2002 10:26 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Streamline xslt


I love using XSLT because I can expose my web pages as xml and use xslt
to transform the xml into html or something else like wml. The
presentation is cleanly separated from content.

The problem I see is if I need to change the presentation. I'm sure
someday at some point someone will say let's give the Website a new
look. Each "page" has a php script that either points to an xml file or
creates xml on the fly, then points to an xsl file and passes this to
the Sablotron processor. To change the site design I have to update each
xsl file in the site.The html is the same for each xsl stylesheet except
the part where the xsl code lives.So ideally I would divide the file
into header.inc, the xsl part and footer.inc.

The first thought I had was use includes. Php includes won't work
because the first thing the Sablotron processor sees is <?php //php code
?>. I assume the same problem occurs with Apache includes.
XSL includes must be well formed xml documents so that wouldn't work
either.

Any suggestions?


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>