xsl-list
[Top] [All Lists]

Re: Web sites: building common components centrally

2004-11-28 02:50:00

___
Kevin Bird
Matrix

...... Original Message .......
On Sat, 27 Nov 2004 08:19:31 -0800 Robert Koberg <rob(_at_)koberg(_dot_)com> 
wrote:
Hi,

We (an application service provider CMS (livestoryboard.com) based on 
XML/XSL.) do something like the following...

Each client project usually defines a layouts.xsl[1] that imports 
several XSLs. The client project can use the applcation defaults for the 
imports or can extend/override them. You would use (in java) a custom 
URIResolver to check the client project's dir structure for a file, if 
not there fallback to the app's default

To overrride an import, the client project could either import their own 
uniquely named xsl file while removing the import for the override or 
create the file (with the same name as the one to override) in the 
project's filesystem.

To extend an existing imported XSL, the client would create the template 
they want to override from the default, but still use the default file. 
For example, head.xsl[2] has a named template that calls other 
templates. If you want to extend the head.xsl without overriding it 
completely you could define one of the named templates in the 
layouts.xsl or some other imported XSL.

Hope this makes sense.

best,
-Rob


[1] A layouts.xsl might look like:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet exclude-result-prefixes="s" version="1.0" 
xmlns:s="http://livestoryboard.com/schemas/lsb"; 
xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <!--
  XSL will be looked first relative to this XSL file. If it is not 
found, the system will lookup an LSB default. If nothing is found it 
will will return an error (null).
  -->
  <xsl:import href="head.xsl"/>
  <xsl:import href="banner.xsl"/>
  <xsl:import href="top-level-nav.xsl"/>
  <xsl:import href="second-level-nav.xsl"/>
  <xsl:import href="topics.xsl"/>
  <xsl:import href="footer.xsl"/>

  <xsl:import href="components/indexer.xsl"/>
  <xsl:import href="components/metadata.xsl"/>
  <xsl:import href="components/toc.xsl"/>
  <xsl:import href="components/pager.xsl"/>
  <xsl:import href="components/snailtrail.xsl"/>

  <xsl:import href="content.xsl"/>
  <xsl:import href="table.xsl"/>
  <xsl:import href="flash.xsl"/>

  <xsl:import href="global_definitions.xsl"/>
  <xsl:import href="metadata_nodesets.xsl"/>
  <xsl:import href="linking.xsl"/>
  <xsl:import href="aggregator.xsl"/>

  <xsl:output
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"

doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
    encoding="utf-8"
    indent="no"
    method="xml"
    omit-xml-declaration="yes"/>

  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml";>
      <xsl:call-template name="head"/>
      <body class="{$lsb_folder_nodeset/@name}">
        <xsl:choose>
          <xsl:when test="$user.focus.layout='default'">
            <xsl:call-template name="default"/>
          </xsl:when>
          <!--<xsl:when test="$user.focus.layout='home'">
            <xsl:call-template name="home"/>
          </xsl:when>
          <xsl:when test="$user.focus.layout='topics'">
            <xsl:call-template name="topics"/>
          </xsl:when>
          <xsl:when test="$user.focus.layout='screenshots'">
            <xsl:call-template name="screenshots"/>
          </xsl:when>-->
          <xsl:otherwise/>
        </xsl:choose>
      </body>
    </html>
  </xsl:template>

  <xsl:template name="default">
    <xsl:call-template name="banner"/>
    <xsl:call-template name="tabs"/>
    <div id="content-main">
      <xsl:if test="$lsb_folder_nodeset/@snailtrail">
        <xsl:call-template name="snailtrail"/>
      </xsl:if>
      <h1>
        <xsl:value-of select="$focus_title"/>
      </h1>
      <xsl:apply-templates mode="load_regions" 
select="$lsb_folder_metadata/s:regions/s:region[(_at_)name='wideColumn']/*"/>
      <xsl:apply-templates mode="load_regions" 
select="$lsb_focus_metadata/s:regions/s:region[(_at_)name='wideColumn']/*"/>
      <xsl:if test="$lsb_folder_nodeset/@pager">
        <xsl:call-template name="pager"/>
      </xsl:if>
    </div>
    <div id="content-sidebar">
      <div id="nav-header">
        <xsl:variable name="href">
          <xsl:apply-templates select="$lsb_folder_nodeset" 
mode="get_page_href"/>
        </xsl:variable>
        <a href="{$href}">
          <xsl:value-of select="$lsb_folder_nodeset/@label"/>
        </a>
        <xsl:text>:</xsl:text>
      </div>
      <xsl:call-template name="nav"/>
      <xsl:apply-templates mode="load_regions" 
select="$lsb_folder_metadata/s:regions/s:region[(_at_)name='narrowCol']/*"/>
      <xsl:apply-templates mode="load_regions" 
select="$lsb_focus_metadata/s:regions/s:region[(_at_)name='narrowCol']/*"/>
      <br class="brkr"/>
    </div>
    <xsl:call-template name="footer"/>
  </xsl:template>

</xsl:stylesheet>


[2] head.xsl's main named template:


  <xsl:template name="head">
    <head>

      <xsl:call-template name="head-misc-before"/>
      <xsl:call-template name="head-css"/>
      <xsl:call-template name="head-favicon"/>
      <xsl:call-template name="head-metadata-misc"/>
      <xsl:call-template name="head-metadata-dc"/>
      <xsl:call-template name="head-title"/>
      <xsl:call-template name="head-misc-after"/>

    </head>
  </xsl:template>




Frans Englich wrote:


Hello,

I am working on a project which as user interface has a web site. The 
software 
is information intensive and produces much data. What the website consists 
of 
is plain informative documents(such as FAQs), and various data files which 
are statically produced. The browser-sophisticance requirement for solving 
my 
problem can be fairly high since the userbase is software developers; 
support 
for client side XSLT transformation can be assumed, if it's deemed 
necessary.

The problem I have is of plain web design: How do I in the best way 
insert 
common elements, such as footers and navigation, into every file which 
is 
part of the website?

Currently, my plan is to write/produce all documents in XHTML, and 
associate 
every file with an XSLT which adds the common parts such as base CSS, 
headers, navigation, footers, and so forth; the styleheet would "merge" 
the 
document with the common elements.

To me it sounds practical, the documents are standalone, valid XHTML 
documents(they can be validated and tested independently) and the 
website 
framework is centrally controlled. Bandwidth can be saved by doing the 
transformation at the client. Perhaps it is restraining if the 
navigation is 
somehow dynamic/context bound, affected by the document, I cannot yet 
tell.

But this is a common problem -- how do people usually solve this?

I've worked with a PHP framework, where documents were written in 
php-tags+body content + php tags, and the php tags then inserted the XML 
declaration, navigation, and head, html tags, and so forth(the documents 
were 
not well-formed). When the documents needed to affect the navigation, 
such as 
to add a menu, they simply declared PHP variables. Apart from that, this 
copy&paste solution was of course a major pain; impossible to validate 
the 
documents, and just think about extending or integrating an XML 
technology, 
such as Docbook..

I might add that I have no dependency on a procedural server-side 
language, 
and it would be nice if it stayed that way.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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